diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2021-06-05 01:06:17 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-08-30 12:08:04 +0200 |
| commit | 3219dd3388c437b4bd869b76ddd43c9cdad05090 (patch) | |
| tree | 53db28fd03110483db1b5f7862e0233d12ee8ebb /tests/migrations/test_executor.py | |
| parent | 9e17cc062c62eec1177aaf65ebebba43e074cde2 (diff) | |
Fixed #24900 -- Allowed migrating backward to squashed migrations.
Diffstat (limited to 'tests/migrations/test_executor.py')
| -rw-r--r-- | tests/migrations/test_executor.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py index fc80c950fa..f8c321b0f3 100644 --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -104,6 +104,29 @@ class ExecutorTests(MigrationTestBase): self.assertTableNotExists("migrations_author") self.assertTableNotExists("migrations_book") + @override_settings( + MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed'}, + ) + def test_migrate_backward_to_squashed_migration(self): + executor = MigrationExecutor(connection) + try: + self.assertTableNotExists('migrations_author') + self.assertTableNotExists('migrations_book') + executor.migrate([('migrations', '0001_squashed_0002')]) + self.assertTableExists('migrations_author') + self.assertTableExists('migrations_book') + executor.loader.build_graph() + # Migrate backward to a squashed migration. + executor.migrate([('migrations', '0001_initial')]) + self.assertTableExists('migrations_author') + self.assertTableNotExists('migrations_book') + finally: + # Unmigrate everything. + executor = MigrationExecutor(connection) + executor.migrate([('migrations', None)]) + self.assertTableNotExists('migrations_author') + self.assertTableNotExists('migrations_book') + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_non_atomic"}) def test_non_atomic_migration(self): """ @@ -733,6 +756,7 @@ class FakeLoader: def __init__(self, graph, applied): self.graph = graph self.applied_migrations = applied + self.replace_migrations = True class FakeMigration: |
