From d7ab2cefb7ec94bf45d37a02c79b6703ea2880e5 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 24 Sep 2014 15:49:30 -0400 Subject: Revert "Fixed #23474 -- Prevented migrating backwards from unapplying the wrong migrations." This reverts commit abcf28a07695a45cb5fb15b81bffc97bea5e0be3. --- django/db/migrations/executor.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'django') diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py index 6ebb21fc0b..32aa82b82c 100644 --- a/django/db/migrations/executor.py +++ b/django/db/migrations/executor.py @@ -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)) -- cgit v1.3