1
1
from django .conf import settings
2
2
from django .core .management .base import BaseCommand , CommandError
3
3
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
6
5
from django .db .migrations .migration import SwappableTuple
7
6
from django .db .migrations .optimizer import MigrationOptimizer
8
7
from django .db .migrations .writer import MigrationWriter
@@ -32,14 +31,14 @@ def handle(self, **options):
32
31
no_optimize = options ['no_optimize' ]
33
32
34
33
# 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 :
37
36
raise CommandError (
38
37
"App '%s' does not have migrations (so squashmigrations on "
39
38
"it makes no sense)" % app_label
40
39
)
41
40
try :
42
- migration = executor . loader .get_migration_by_prefix (app_label , migration_name )
41
+ migration = loader .get_migration_by_prefix (app_label , migration_name )
43
42
except AmbiguityError :
44
43
raise CommandError (
45
44
"More than one migration matches '%s' in app '%s'. Please be "
@@ -53,8 +52,8 @@ def handle(self, **options):
53
52
54
53
# Work out the list of predecessor migrations
55
54
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 ))
58
57
if al == migration .app_label
59
58
]
60
59
0 commit comments