Avoided transactional truncates on amateur databases.
Fixed a test failure that appeared after 753a22a6
, although the bug
existed before that commit.
Refs #22308.
This commit is contained in:
parent
ee4edb1eda
commit
6877a9d415
|
@ -28,8 +28,8 @@ class Command(NoArgsCommand):
|
||||||
're-executed, and the initial_data fixture will be re-installed.')
|
're-executed, and the initial_data fixture will be re-installed.')
|
||||||
|
|
||||||
def handle_noargs(self, **options):
|
def handle_noargs(self, **options):
|
||||||
db = options.get('database')
|
database = options.get('database')
|
||||||
connection = connections[db]
|
connection = connections[database]
|
||||||
verbosity = int(options.get('verbosity'))
|
verbosity = int(options.get('verbosity'))
|
||||||
interactive = options.get('interactive')
|
interactive = options.get('interactive')
|
||||||
# The following are stealth options used by Django's internals.
|
# The following are stealth options used by Django's internals.
|
||||||
|
@ -63,7 +63,8 @@ Are you sure you want to do this?
|
||||||
|
|
||||||
if confirm == 'yes':
|
if confirm == 'yes':
|
||||||
try:
|
try:
|
||||||
with transaction.atomic(using=db):
|
with transaction.atomic(using=database,
|
||||||
|
savepoint=connection.features.can_rollback_ddl):
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
for sql in sql_list:
|
for sql in sql_list:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
@ -78,7 +79,7 @@ Are you sure you want to do this?
|
||||||
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
|
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
|
||||||
|
|
||||||
if not inhibit_post_migrate:
|
if not inhibit_post_migrate:
|
||||||
self.emit_post_migrate(verbosity, interactive, db)
|
self.emit_post_migrate(verbosity, interactive, database)
|
||||||
|
|
||||||
# Reinstall the initial_data fixture.
|
# Reinstall the initial_data fixture.
|
||||||
if options.get('load_initial_data'):
|
if options.get('load_initial_data'):
|
||||||
|
|
Loading…
Reference in New Issue