Fixed #24900 -- Allowed migrating backward to squashed migrations.

This commit is contained in:
Jacob Walls 2021-06-05 01:06:17 -04:00 committed by Mariusz Felisiak
parent 9e17cc062c
commit 3219dd3388
3 changed files with 46 additions and 0 deletions

View file

@ -980,6 +980,19 @@ class MigrateTests(MigrationTestBase):
# Unmigrate everything.
call_command('migrate', 'migrations', 'zero', verbosity=0)
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed'})
def test_migrate_backward_to_squashed_migration(self):
try:
call_command('migrate', 'migrations', '0001_squashed_0002', verbosity=0)
self.assertTableExists('migrations_author')
self.assertTableExists('migrations_book')
call_command('migrate', 'migrations', '0001_initial', verbosity=0)
self.assertTableExists('migrations_author')
self.assertTableNotExists('migrations_book')
finally:
# Unmigrate everything.
call_command('migrate', 'migrations', 'zero', verbosity=0)
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations'})
def test_migrate_inconsistent_history(self):
"""