1
0
mirror of https://github.com/django/django.git synced 2024-12-26 02:56:25 +00:00

Use new transaction API in syncdb section of migrate

This commit is contained in:
Andrew Godwin 2013-07-26 16:39:44 +01:00
parent 6b39010d57
commit c1ed21fa9e

View File

@ -12,7 +12,7 @@ from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.loader import AmbiguityError from django.db.migrations.loader import AmbiguityError
from django.utils.datastructures import SortedDict from django.utils.datastructures import SortedDict
from django.utils.importlib import import_module from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule, import_by_path from django.utils.module_loading import module_has_submodule
class Command(BaseCommand): class Command(BaseCommand):
@ -162,7 +162,7 @@ class Command(BaseCommand):
# Create the tables for each model # Create the tables for each model
if self.verbosity >= 1: if self.verbosity >= 1:
self.stdout.write(" Creating tables...\n") self.stdout.write(" Creating tables...\n")
with transaction.commit_on_success_unless_managed(using=connection.alias): with transaction.atomic(using=connection.alias, savepoint=False):
for app_name, model_list in manifest.items(): for app_name, model_list in manifest.items():
for model in model_list: for model in model_list:
# Create the model's database table, if it doesn't already exist. # Create the model's database table, if it doesn't already exist.
@ -182,6 +182,10 @@ class Command(BaseCommand):
cursor.execute(statement) cursor.execute(statement)
tables.append(connection.introspection.table_name_converter(model._meta.db_table)) tables.append(connection.introspection.table_name_converter(model._meta.db_table))
# We force a commit here, as that was the previous behaviour.
# If you can prove we don't need this, remove it.
transaction.set_dirty(using=connection.alias)
# Send the post_syncdb signal, so individual apps can do whatever they need # Send the post_syncdb signal, so individual apps can do whatever they need
# to do at this point. # to do at this point.
emit_post_sync_signal(created_models, self.verbosity, self.interactive, connection.alias) emit_post_sync_signal(created_models, self.verbosity, self.interactive, connection.alias)