diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/executor.py | 14 |
1 files changed, 5 insertions, 9 deletions
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)) |
