summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2016-01-09 03:12:46 -0500
committerSimon Charette <charette.s@gmail.com>2016-01-23 14:19:03 -0500
commit729e0b086daac92bb9c6eb16f01cd2e13d258fdd (patch)
tree471c48b17d72c13976f4f772426580b3252ff7bf /docs/ref
parent49f4c9f4c61885189d136d7073c26ecc91b482b1 (diff)
Fixed #24109 -- Allowed RunSQL and RunPython operations to be elided.
Thanks to Markus Holtermann and Tim Graham for their review.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/migration-operations.txt18
1 files changed, 16 insertions, 2 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt
index 5b8a6c14a5..6255176f80 100644
--- a/docs/ref/migration-operations.txt
+++ b/docs/ref/migration-operations.txt
@@ -196,7 +196,7 @@ Special Operations
RunSQL
------
-.. class:: RunSQL(sql, reverse_sql=None, state_operations=None, hints=None)
+.. class:: RunSQL(sql, reverse_sql=None, state_operations=None, hints=None, elidable=False)
Allows running of arbitrary SQL on the database - useful for more advanced
features of database backends that Django doesn't support directly, like
@@ -249,6 +249,9 @@ The optional ``hints`` argument will be passed as ``**hints`` to the
routing decisions. See :ref:`topics-db-multi-db-hints` for more details on
database hints.
+The optional ``elidable`` argument determines whether or not the operation will
+be removed (elided) when :ref:`squashing migrations <migration-squashing>`.
+
.. attribute:: RunSQL.noop
Pass the ``RunSQL.noop`` attribute to ``sql`` or ``reverse_sql`` when you
@@ -257,10 +260,14 @@ database hints.
.. _sqlparse: https://pypi.python.org/pypi/sqlparse
+.. versionadded:: 1.10
+
+ The ``elidable`` argument was added.
+
RunPython
---------
-.. class:: RunPython(code, reverse_code=None, atomic=True, hints=None)
+.. class:: RunPython(code, reverse_code=None, atomic=True, hints=None, elidable=False)
Runs custom Python code in a historical context. ``code`` (and ``reverse_code``
if supplied) should be callable objects that accept two arguments; the first is
@@ -278,6 +285,9 @@ The optional ``hints`` argument will be passed as ``**hints`` to the
routing decision. See :ref:`topics-db-multi-db-hints` for more details on
database hints.
+The optional ``elidable`` argument determines whether or not the operation will
+be removed (elided) when :ref:`squashing migrations <migration-squashing>`.
+
You are advised to write the code as a separate function above the ``Migration``
class in the migration file, and just pass it to ``RunPython``. Here's an
example of using ``RunPython`` to create some initial objects on a ``Country``
@@ -366,6 +376,10 @@ attribute.
you want the operation not to do anything in the given direction. This is
especially useful in making the operation reversible.
+.. versionadded:: 1.10
+
+ The ``elidable`` argument was added.
+
SeparateDatabaseAndState
------------------------