summaryrefslogtreecommitdiff
path: root/django/db/migrations/executor.py
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-03-30 08:18:18 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-04-01 09:35:37 +0200
commita0fb35eb726f1a04eaa1b47b8de191fafe55a0ab (patch)
tree8783e5f447feeb4b5201900b1628511ebcee0118 /django/db/migrations/executor.py
parent12385b4fa7059aab8e4f671853cc09ae8509501f (diff)
Fixed #36184 -- Allowed migrating forward to squashed migrations.
Diffstat (limited to 'django/db/migrations/executor.py')
-rw-r--r--django/db/migrations/executor.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
index ebfe8572fe..61b2b54f6c 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -37,18 +37,18 @@ class MigrationExecutor:
if migration in applied:
plan.append((self.loader.graph.nodes[migration], True))
applied.pop(migration)
+ # If the target is missing, it's likely a replaced migration.
+ # Reload the graph without replacements.
+ elif (
+ self.loader.replace_migrations
+ and target not in self.loader.graph.node_map
+ ):
+ self.loader.replace_migrations = False
+ self.loader.build_graph()
+ return self.migration_plan(targets, clean_start=clean_start)
# If the migration is already applied, do backwards mode,
# otherwise do forwards mode.
elif target in applied:
- # If the target is missing, it's likely a replaced migration.
- # Reload the graph without replacements.
- if (
- self.loader.replace_migrations
- and target not in self.loader.graph.node_map
- ):
- self.loader.replace_migrations = False
- self.loader.build_graph()
- return self.migration_plan(targets, clean_start=clean_start)
# Don't migrate backwards all the way to the target node (that
# may roll back dependencies in other apps that don't need to
# be rolled back); instead roll back through target's immediate