summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-08-11 15:28:51 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-08-11 15:28:51 +0100
commitb61b6346284fb32614aab965bd2cb09b383fc9f5 (patch)
tree874d33e275f34761150fd06ddbc2b20bf1aaeec1 /django
parentb4c493ecd3b8d0d55347949984561762ad2ef1dc (diff)
Fix weird planning issues when already fully migrated.
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/executor.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
index 9d99c90c11..fe0ac6b061 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -33,10 +33,15 @@ class MigrationExecutor(object):
# If the migration is already applied, do backwards mode,
# otherwise do forwards mode.
elif target in applied:
- for migration in self.loader.graph.backwards_plan(target)[:-1]:
- if migration in applied:
- plan.append((self.loader.graph.nodes[migration], True))
- applied.remove(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))
+ applied.remove(migration)
else:
for migration in self.loader.graph.forwards_plan(target):
if migration not in applied: