summaryrefslogtreecommitdiff
path: root/django/db/migrations/executor.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2021-01-20 19:00:36 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-21 07:35:43 +0100
commit6520ce5251e7d63d08bf965e5ca00e508f8a8613 (patch)
treea157e402d8435ec5f6b3589319caf3d586b9c8d1 /django/db/migrations/executor.py
parent900b2ce92bd68fb4b17e923cffdbde30eb24f7d2 (diff)
[3.2.x] Fixed #32374 -- Stopped recording migration application before deferred SQL.
Migrations cannot be recorded in the same transaction as its associated DDL operations when some of it is deferred until the schema editor context exits. Regression in c86a3d80a25acd1887319198ca21a84c451014ad. Backport of 0c42cdf0d2422f4c080e93594d5d15381d6e955e from master
Diffstat (limited to 'django/db/migrations/executor.py')
-rw-r--r--django/db/migrations/executor.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
index 83d624e08a..57042a8690 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -225,8 +225,9 @@ class MigrationExecutor:
# Alright, do it normally
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
state = migration.apply(state, schema_editor)
- self.record_migration(migration)
- migration_recorded = True
+ if not schema_editor.deferred_sql:
+ self.record_migration(migration)
+ migration_recorded = True
if not migration_recorded:
self.record_migration(migration)
# Report progress