mirror of https://github.com/django/django.git
Fixed #25255 -- Recorded unapplied squashed migrations.
This commit is contained in:
parent
8c3bd0b708
commit
c0e29cec83
|
@ -250,12 +250,11 @@ class MigrationExecutor:
|
||||||
if not fake:
|
if not fake:
|
||||||
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
|
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
|
||||||
state = migration.unapply(state, schema_editor)
|
state = migration.unapply(state, schema_editor)
|
||||||
# For replacement migrations, record individual statuses
|
# For replacement migrations, also record individual statuses.
|
||||||
if migration.replaces:
|
if migration.replaces:
|
||||||
for app_label, name in migration.replaces:
|
for app_label, name in migration.replaces:
|
||||||
self.recorder.record_unapplied(app_label, name)
|
self.recorder.record_unapplied(app_label, name)
|
||||||
else:
|
self.recorder.record_unapplied(migration.app_label, migration.name)
|
||||||
self.recorder.record_unapplied(migration.app_label, migration.name)
|
|
||||||
# Report progress
|
# Report progress
|
||||||
if self.progress_callback:
|
if self.progress_callback:
|
||||||
self.progress_callback("unapply_success", migration, fake)
|
self.progress_callback("unapply_success", migration, fake)
|
||||||
|
|
|
@ -653,6 +653,23 @@ class ExecutorTests(MigrationTestBase):
|
||||||
recorder.applied_migrations(),
|
recorder.applied_migrations(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed'})
|
||||||
|
def test_migrate_marks_replacement_unapplied(self):
|
||||||
|
executor = MigrationExecutor(connection)
|
||||||
|
executor.migrate([('migrations', '0001_squashed_0002')])
|
||||||
|
try:
|
||||||
|
self.assertIn(
|
||||||
|
('migrations', '0001_squashed_0002'),
|
||||||
|
executor.recorder.applied_migrations(),
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
executor.loader.build_graph()
|
||||||
|
executor.migrate([('migrations', None)])
|
||||||
|
self.assertNotIn(
|
||||||
|
('migrations', '0001_squashed_0002'),
|
||||||
|
executor.recorder.applied_migrations(),
|
||||||
|
)
|
||||||
|
|
||||||
# When the feature is False, the operation and the record won't be
|
# When the feature is False, the operation and the record won't be
|
||||||
# performed in a transaction and the test will systematically pass.
|
# performed in a transaction and the test will systematically pass.
|
||||||
@skipUnlessDBFeature('can_rollback_ddl')
|
@skipUnlessDBFeature('can_rollback_ddl')
|
||||||
|
|
Loading…
Reference in New Issue