diff options
| author | Tim Graham <timograham@gmail.com> | 2015-05-13 08:19:51 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-17 18:50:18 -0400 |
| commit | 307acc745a4e655c35db96f96ceb4b87597dee49 (patch) | |
| tree | 1e4843f968980406a521186946eaf3cf63299621 /docs/ref | |
| parent | fc1eea59c0c09b306f0391735491fa43cbed4d7a (diff) | |
Fixed #24630 -- Clarified docs about RunPython transactions.
Thanks Markus Holtermann for review.
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 991cc6f33b..31ea32ee9d 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -322,11 +322,23 @@ or that you use :class:`SeparateDatabaseAndState` to add in operations that will reflect your changes to the model state - otherwise, the versioned ORM and the autodetector will stop working correctly. -By default, ``RunPython`` will run its contents inside a transaction even -on databases that do not support DDL transactions (for example, MySQL and +By default, ``RunPython`` will run its contents inside a transaction on +databases that do not support DDL transactions (for example, MySQL and Oracle). This should be safe, but may cause a crash if you attempt to use -the ``schema_editor`` provided on these backends; in this case, please -set ``atomic=False``. +the ``schema_editor`` provided on these backends; in this case, pass +``atomic=False`` to the ``RunPython`` operation. + +On databases that do support DDL transactions (SQLite and PostgreSQL), +``RunPython`` operations do not have any transactions automatically added +besides the transactions created for each migration (the ``atomic`` parameter +has no effect on these databases). Thus, on PostgreSQL, for example, you should +avoid combining schema changes and ``RunPython`` operations in the same +migration or you may hit errors like ``OperationalError: cannot ALTER TABLE +"mytable" because it has pending trigger events``. + +If you have a different database and aren't sure if it supports DDL +transactions, check the ``django.db.connection.features.can_rollback_ddl`` +attribute. .. warning:: |
