mirror of
https://github.com/django/django.git
synced 2024-12-24 18:16:19 +00:00
Wrapped migrations in a transaction only on DBs with transactional DDL.
This commit is contained in:
parent
3a435a057c
commit
e74d2183c2
@ -71,14 +71,16 @@ class BaseDatabaseSchemaEditor(object):
|
|||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.deferred_sql = []
|
self.deferred_sql = []
|
||||||
atomic(self.connection.alias, self.connection.features.can_rollback_ddl).__enter__()
|
if self.connection.features.can_rollback_ddl:
|
||||||
|
atomic(self.connection.alias).__enter__()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
if exc_type is None:
|
if exc_type is None:
|
||||||
for sql in self.deferred_sql:
|
for sql in self.deferred_sql:
|
||||||
self.execute(sql)
|
self.execute(sql)
|
||||||
atomic(self.connection.alias, self.connection.features.can_rollback_ddl).__exit__(exc_type, exc_value, traceback)
|
if self.connection.features.can_rollback_ddl:
|
||||||
|
atomic(self.connection.alias).__exit__(exc_type, exc_value, traceback)
|
||||||
|
|
||||||
# Core utility functions
|
# Core utility functions
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user