Refs -- Added MigrationLoader test for applying squashed migrations.
@@ -485,6 +485,27 @@ class LoaderTests(TestCase):
}
self.assertEqual(plan, expected_plan)
+ # Load with nothing applied and migrate to a replaced migration.
+ # Not possible if loader.replace_migrations is True (default).
+ loader.build_graph()
+ msg = "Node ('app1', '3_auto') not a valid node"
+ with self.assertRaisesMessage(NodeNotFoundError, msg):
+ loader.graph.forwards_plan(('app1', '3_auto'))
+ # Possible if loader.replace_migrations is False.
+ loader.replace_migrations = False
+ loader.build_graph()
+ plan = set(loader.graph.forwards_plan(('app1', '3_auto')))
+ plan = plan - loader.applied_migrations.keys()
+ expected_plan = {
+ ('app1', '1_auto'),
+ ('app2', '1_auto'),
+ ('app2', '2_auto'),
+ ('app1', '2_auto'),
+ ('app1', '3_auto'),
+ }
+ self.assertEqual(plan, expected_plan)
+ loader.replace_migrations = True
+
# Fake-apply a few from app1: unsquashes migration in app1.
self.record_applied(recorder, 'app1', '1_auto')
self.record_applied(recorder, 'app1', '2_auto')
