Tests running a simple set of migrations.
(self)
| 37 | |
| 38 | @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) |
| 39 | def test_run(self): |
| 40 | """ |
| 41 | Tests running a simple set of migrations. |
| 42 | """ |
| 43 | executor = MigrationExecutor(connection) |
| 44 | # Let's look at the plan first and make sure it's up to scratch |
| 45 | plan = executor.migration_plan([("migrations", "0002_second")]) |
| 46 | self.assertEqual( |
| 47 | plan, |
| 48 | [ |
| 49 | (executor.loader.graph.nodes["migrations", "0001_initial"], False), |
| 50 | (executor.loader.graph.nodes["migrations", "0002_second"], False), |
| 51 | ], |
| 52 | ) |
| 53 | # Were the tables there before? |
| 54 | self.assertTableNotExists("migrations_author") |
| 55 | self.assertTableNotExists("migrations_book") |
| 56 | # Alright, let's try running it |
| 57 | executor.migrate([("migrations", "0002_second")]) |
| 58 | # Are the tables there now? |
| 59 | self.assertTableExists("migrations_author") |
| 60 | self.assertTableExists("migrations_book") |
| 61 | # Rebuild the graph to reflect the new DB state |
| 62 | executor.loader.build_graph() |
| 63 | # Alright, let's undo what we did |
| 64 | plan = executor.migration_plan([("migrations", None)]) |
| 65 | self.assertEqual( |
| 66 | plan, |
| 67 | [ |
| 68 | (executor.loader.graph.nodes["migrations", "0002_second"], True), |
| 69 | (executor.loader.graph.nodes["migrations", "0001_initial"], True), |
| 70 | ], |
| 71 | ) |
| 72 | executor.migrate([("migrations", None)]) |
| 73 | # Are the tables gone? |
| 74 | self.assertTableNotExists("migrations_author") |
| 75 | self.assertTableNotExists("migrations_book") |
| 76 | |
| 77 | @override_settings( |
| 78 | MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"} |
nothing calls this directly
no test coverage detected