diff --git a/django/core/management/commands/sqlmigrate.py b/django/core/management/commands/sqlmigrate.py index d05e615c898..2acb789c002 100644 --- a/django/core/management/commands/sqlmigrate.py +++ b/django/core/management/commands/sqlmigrate.py @@ -1,8 +1,7 @@ from django.apps import apps from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS, connections -from django.db.migrations.executor import MigrationExecutor -from django.db.migrations.loader import AmbiguityError +from django.db.migrations.loader import AmbiguityError, MigrationLoader class Command(BaseCommand): @@ -33,8 +32,8 @@ class Command(BaseCommand): # Get the database we're operating from connection = connections[options['database']] - # Load up an executor to get all the migration data - executor = MigrationExecutor(connection) + # Load up an loader to get all the migration data + loader = MigrationLoader(connection) # Resolve command-line arguments into a migration app_label, migration_name = options['app_label'], options['migration_name'] @@ -43,10 +42,10 @@ class Command(BaseCommand): apps.get_app_config(app_label) except LookupError as err: raise CommandError(str(err)) - if app_label not in executor.loader.migrated_apps: + if app_label not in loader.migrated_apps: raise CommandError("App '%s' does not have migrations" % app_label) try: - migration = executor.loader.get_migration_by_prefix(app_label, migration_name) + migration = loader.get_migration_by_prefix(app_label, migration_name) except AmbiguityError: raise CommandError("More than one migration matches '%s' in app '%s'. Please be more specific." % ( migration_name, app_label)) @@ -61,8 +60,8 @@ class Command(BaseCommand): # Make a plan that represents just the requested migrations and show SQL # for it - plan = [(executor.loader.graph.nodes[target], options['backwards'])] - sql_statements = executor.loader.collect_sql(plan) + plan = [(loader.graph.nodes[target], options['backwards'])] + sql_statements = loader.collect_sql(plan) if not sql_statements and options['verbosity'] >= 1: self.stderr.write('No operations found.') return '\n'.join(sql_statements)