[1.8.x] Refs #24628 -- Added a second test and a docstring comment to avoid regression.

Backport of 5c085ea7b3 from master.
This commit is contained in:
Carl Meyer 2015-06-03 13:46:01 -06:00
parent f082813d67
commit feed5ad2a0
2 changed files with 32 additions and 0 deletions

View file

@ -437,6 +437,30 @@ class ExecutorTests(MigrationTestBase):
recorder.applied_migrations(),
)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"})
def test_migrate_marks_replacement_applied_even_if_it_did_nothing(self):
"""
A new squash migration will be marked as applied even if all its
replaced migrations were previously already applied.
Ticket #24628.
"""
recorder = MigrationRecorder(connection)
# Record all replaced migrations as applied
recorder.record_applied("migrations", "0001_initial")
recorder.record_applied("migrations", "0002_second")
executor = MigrationExecutor(connection)
executor.migrate([("migrations", "0001_squashed_0002")])
# Because 0001 and 0002 are both applied, even though this migrate run
# didn't apply anything new, their squashed replacement should be
# marked as applied.
self.assertIn(
("migrations", "0001_squashed_0002"),
recorder.applied_migrations(),
)
class FakeLoader(object):
def __init__(self, graph, applied):