Optimized a bit handle() of sqlmigrate management command.
This commit is contained in:
parent
8c1b073b59
commit
e12fea24f0
|
@ -53,7 +53,7 @@ class Command(BaseCommand):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise CommandError("Cannot find a migration matching '%s' from app '%s'. Is it in INSTALLED_APPS?" % (
|
raise CommandError("Cannot find a migration matching '%s' from app '%s'. Is it in INSTALLED_APPS?" % (
|
||||||
migration_name, app_label))
|
migration_name, app_label))
|
||||||
targets = [(app_label, migration.name)]
|
target = (app_label, migration.name)
|
||||||
|
|
||||||
# Show begin/end around output for atomic migrations, if the database
|
# Show begin/end around output for atomic migrations, if the database
|
||||||
# supports transactional DDL.
|
# supports transactional DDL.
|
||||||
|
@ -61,7 +61,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Make a plan that represents just the requested migrations and show SQL
|
# Make a plan that represents just the requested migrations and show SQL
|
||||||
# for it
|
# for it
|
||||||
plan = [(executor.loader.graph.nodes[targets[0]], options['backwards'])]
|
plan = [(executor.loader.graph.nodes[target], options['backwards'])]
|
||||||
sql_statements = executor.collect_sql(plan)
|
sql_statements = executor.collect_sql(plan)
|
||||||
if not sql_statements and options['verbosity'] >= 1:
|
if not sql_statements and options['verbosity'] >= 1:
|
||||||
self.stderr.write('No operations found.')
|
self.stderr.write('No operations found.')
|
||||||
|
|
Loading…
Reference in New Issue