Tests running a squashed migration from zero (should ignore what it replaces)
(self)
| 78 | MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"} |
| 79 | ) |
| 80 | def test_run_with_squashed(self): |
| 81 | """ |
| 82 | Tests running a squashed migration from zero (should ignore what it |
| 83 | replaces) |
| 84 | """ |
| 85 | executor = MigrationExecutor(connection) |
| 86 | # Check our leaf node is the squashed one |
| 87 | leaves = [ |
| 88 | key for key in executor.loader.graph.leaf_nodes() if key[0] == "migrations" |
| 89 | ] |
| 90 | self.assertEqual(leaves, [("migrations", "0001_squashed_0002")]) |
| 91 | # Check the plan |
| 92 | plan = executor.migration_plan([("migrations", "0001_squashed_0002")]) |
| 93 | self.assertEqual( |
| 94 | plan, |
| 95 | [ |
| 96 | ( |
| 97 | executor.loader.graph.nodes["migrations", "0001_squashed_0002"], |
| 98 | False, |
| 99 | ), |
| 100 | ], |
| 101 | ) |
| 102 | # Were the tables there before? |
| 103 | self.assertTableNotExists("migrations_author") |
| 104 | self.assertTableNotExists("migrations_book") |
| 105 | # Alright, let's try running it |
| 106 | executor.migrate([("migrations", "0001_squashed_0002")]) |
| 107 | # Are the tables there now? |
| 108 | self.assertTableExists("migrations_author") |
| 109 | self.assertTableExists("migrations_book") |
| 110 | # Rebuild the graph to reflect the new DB state |
| 111 | executor.loader.build_graph() |
| 112 | # Alright, let's undo what we did. Should also just use squashed. |
| 113 | plan = executor.migration_plan([("migrations", None)]) |
| 114 | self.assertEqual( |
| 115 | plan, |
| 116 | [ |
| 117 | (executor.loader.graph.nodes["migrations", "0001_squashed_0002"], True), |
| 118 | ], |
| 119 | ) |
| 120 | executor.migrate([("migrations", None)]) |
| 121 | # Are the tables gone? |
| 122 | self.assertTableNotExists("migrations_author") |
| 123 | self.assertTableNotExists("migrations_book") |
| 124 | |
| 125 | @override_settings( |
| 126 | MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"}, |
nothing calls this directly
no test coverage detected