diff options
| author | Adam Johnson <me@adamj.eu> | 2020-03-03 17:51:39 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-03-10 11:14:05 +0100 |
| commit | 6b41f07720be7c817a8023905a1f55d72f534327 (patch) | |
| tree | 03d4338a2cf805c654c2b9841f891c35212e8414 /docs/ref | |
| parent | 0f524f56864e8894a8229d16a96582d80c78d939 (diff) | |
[3.0.x] Clarified SeparateDatabaseAndState docs and added example of changing ManyToManyField.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-Authored-By: Carlton Gibson <carlton.gibson@noumenal.es>
Co-Authored-By: René Fleschenberg <rene@fleschenberg.net>
Backport of a9ee6872bd9e1bacc2da827dbd5b9093f724e4a5 from master
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/migration-operations.txt | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt index 7cc9bd550a..27ffc43c52 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -423,12 +423,24 @@ if ``atomic=True`` is passed to the ``RunPython`` operation. .. class:: SeparateDatabaseAndState(database_operations=None, state_operations=None) -A highly specialized operation that let you mix and match the database +A highly specialized operation that lets you mix and match the database (schema-changing) and state (autodetector-powering) aspects of operations. -It accepts two lists of operations, and when asked to apply state will use the -state list, and when asked to apply changes to the database will use the database -list. Do not use this operation unless you're very sure you know what you're doing. +It accepts two lists of operations. When asked to apply state, it will use the +``state_operations`` list (this is a generalized version of :class:`RunSQL`'s +``state_operations`` argument). When asked to apply changes to the database, it +will use the ``database_operations`` list. + +If the actual state of the database and Django's view of the state get out of +sync, this can break the migration framework, even leading to data loss. It's +worth exercising caution and checking your database and state operations +carefully. You can use :djadmin:`sqlmigrate` and :djadmin:`dbshell` to check +your database operations. You can use :djadmin:`makemigrations`, especially +with :option:`--dry-run<makemigrations --dry-run>`, to check your state +operations. + +For an example using ``SeparateDatabaseAndState``, see +:ref:`changing-a-manytomanyfield-to-use-a-through-model`. .. _writing-your-own-migration-operation: |
