8000 Fixed #24703 -- Changed squashmigrations to use a MigrationLoader · ddriddle/django@1521861 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1521861

Browse files
knbkMarkusH
authored andcommitted
Fixed #24703 -- Changed squashmigrations to use a MigrationLoader
Changed squashmigrations to not instantiate a MigrationExecutor, but to directly use a MigrationLoader instance instead.
1 parent 0cf7477 commit 1521861

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

django/core/management/commands/squashmigrations.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from django.conf import settings
22
from django.core.management.base import BaseCommand, CommandError
33
from django.db import DEFAULT_DB_ALIAS, connections, migrations
4-
from django.db.migrations.executor import MigrationExecutor
5-
from django.db.migrations.loader import AmbiguityError
4+
from django.db.migrations.loader import AmbiguityError, MigrationLoader
65
from django.db.migrations.migration import SwappableTuple
76
from django.db.migrations.optimizer import MigrationOptimizer
87
from django.db.migrations.writer import MigrationWriter
@@ -32,14 +31,14 @@ def handle(self, **options):
3231
no_optimize = options['no_optimize']
3332

3433
# Load the current graph state, check the app and migration they asked for exists
35-
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
36-
if app_label not in executor.loader.migrated_apps:
34+
loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])
35+
if app_label not in loader.migrated_apps:
3736
raise CommandError(
3837
"App '%s' does not have migrations (so squashmigrations on "
3938
"it makes no sense)" % app_label
4039
)
4140
try:
42-
migration = executor.loader.get_migration_by_prefix(app_label, migration_name)
41+
migration = loader.get_migration_by_prefix(app_label, migration_name)
4342
except AmbiguityError:
4443
raise CommandError(
4544
"More than one migration matches '%s' in app '%s'. Please be "
@@ -53,8 +52,8 @@ def handle(self, **options):
5352

5453
# Work out the list of predecessor migrations
5554
migrations_to_squash = [
56-
executor.loader.get_migration(al, mn)
57-
for al, mn in executor.loader.graph.forwards_plan((migration.app_label, migration.name))
55+
loader.get_migration(al, mn)
56+
for al, mn in loader.graph.forwards_plan((migration.app_label, migration.name))
5857
if al == migration.app_label
5958
]
6059

0 commit comments

Comments
 (0)
0