1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

[1.8.x] Fixed #24628 -- Fixed applied status for squashed migrations.

Backport of 492537ac18 from master.
This commit is contained in:
Carl Meyer
2015-06-02 14:23:07 -06:00
parent c37c6dc410
commit efdcd13c34
4 changed files with 42 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ class MigrationExecutor(object):
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
else:
self.unapply_migration(states[migration], migration, fake=fake)
self.check_replacements()
def collect_sql(self, plan):
"""
@@ -176,6 +177,16 @@ class MigrationExecutor(object):
self.progress_callback("unapply_success", migration, fake)
return state
def check_replacements(self):
"""
Mark replacement migrations applied if their replaced set all are.
"""
applied = self.recorder.applied_migrations()
for key, migration in self.loader.replacements.items():
all_applied = all(m in applied for m in migration.replaces)
if all_applied and key not in applied:
self.recorder.record_applied(*key)
def detect_soft_applied(self, project_state, migration):
"""
Tests whether a migration has been implicitly applied - that the

View File

@@ -249,6 +249,8 @@ class MigrationLoader(object):
# Mark the replacement as applied if all its replaced ones are
if all(applied_statuses):
self.applied_migrations.add(key)
# Store the replacement migrations for later checks
self.replacements = replacing
# Finally, make a graph and load everything into it
self.graph = MigrationGraph()
for key, migration in normal.items():