diff options
| author | Caio Ariede <caio.ariede@gmail.com> | 2020-10-19 09:45:04 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-29 08:39:43 +0100 |
| commit | 62f6ab2c4a2bbf1b5354bca268dcd43be8537785 (patch) | |
| tree | 54266c935b42ebe2e68813bccff7c611d58df963 /docs | |
| parent | b3d667f20dace1ec34525a423467f16e2f3dda51 (diff) | |
[3.1.x] Fixed #26962 -- Doc'd running migrations in transactions.
Backport of 9ca22c7733efeeb140b75585c6387ef2cb861d19 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/migrations.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt index 2d609f01da..50c2cc4f52 100644 --- a/docs/topics/migrations.txt +++ b/docs/topics/migrations.txt @@ -169,6 +169,27 @@ migrations for you. If not, you'll have to go in and modify the migrations yourself - don't worry, this isn't difficult, and is explained more in :ref:`migration-files` below. +Transactions +============ + +On databases that support DDL transactions (SQLite and PostgreSQL), all +migration operations will run inside a single transaction by default. In +contrast, if a database doesn't support DDL transactions (e.g. MySQL, Oracle) +then all operations will run without a transaction. + +You can prevent a migration from running in a transaction by setting the +``atomic`` attribute to ``False``. For example:: + + from django.db import migrations + + class Migration(migrations.Migration): + atomic = False + +It's also possible to execute parts of the migration inside a transaction using +:func:`~django.db.transaction.atomic()` or by passing ``atomic=True`` to +:class:`~django.db.migrations.operations.RunPython`. See +:ref:`non-atomic-migrations` for more details. + Dependencies ============ |
