mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.7.x] Revert "Fixed #23474 -- Prevented migrating backwards from unapplying the wrong migrations."
Backport of d7ab2cefb7 from master
This commit is contained in:
@@ -36,15 +36,11 @@ class MigrationExecutor(object):
|
||||
# If the migration is already applied, do backwards mode,
|
||||
# otherwise do forwards mode.
|
||||
elif target in applied:
|
||||
app_label = target[0]
|
||||
next_migration_prefix = str(int(target[1][:4]) + 1)
|
||||
try:
|
||||
next_migration = self.loader.get_migration_by_prefix(app_label, next_migration_prefix)
|
||||
except KeyError:
|
||||
# If `target` is the most recent one in its app, there is nothing to do.
|
||||
pass
|
||||
else:
|
||||
backwards_plan = self.loader.graph.backwards_plan(next_migration)
|
||||
backwards_plan = self.loader.graph.backwards_plan(target)[:-1]
|
||||
# We only do this if the migration is not the most recent one
|
||||
# in its app - that is, another migration with the same app
|
||||
# label is in the backwards plan
|
||||
if any(node[0] == target[0] for node in backwards_plan):
|
||||
for migration in backwards_plan:
|
||||
if migration in applied:
|
||||
plan.append((self.loader.graph.nodes[migration], True))
|
||||
|
||||
Reference in New Issue
Block a user