Refs #24900 -- Added MigrationLoader test for applying squashed migrations.

This commit is contained in:
Jacob Walls 2021-06-06 14:45:36 -04:00 committed by Mariusz Felisiak
parent cbba49971b
commit 9e17cc062c
1 changed files with 21 additions and 0 deletions

View File

@ -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')