MCPcopy
hub / github.com/django/django / test_migrate_prune

Method test_migrate_prune

tests/migrations/test_commands.py:1481–1509  ·  view source on GitHub ↗

With prune=True, references to migration files deleted from the migrations module (such as after being squashed) are removed from the django_migrations table.

(self)

Source from the content-addressed store, hash-verified

1479 }
1480 )
1481 def test_migrate_prune(self):
1482 """
1483 With prune=True, references to migration files deleted from the
1484 migrations module (such as after being squashed) are removed from the
1485 django_migrations table.
1486 """
1487 recorder = MigrationRecorder(connection)
1488 recorder.record_applied("migrations", "0001_initial")
1489 recorder.record_applied("migrations", "0002_second")
1490 recorder.record_applied("migrations", "0001_squashed_0002")
1491 out = io.StringIO()
1492 try:
1493 call_command("migrate", "migrations", prune=True, stdout=out, no_color=True)
1494 self.assertEqual(
1495 out.getvalue(),
1496 "Pruning migrations:\n"
1497 " Pruning migrations.0001_initial OK\n"
1498 " Pruning migrations.0002_second OK\n",
1499 )
1500 applied_migrations = [
1501 migration
1502 for migration in recorder.applied_migrations()
1503 if migration[0] == "migrations"
1504 ]
1505 self.assertEqual(applied_migrations, [("migrations", "0001_squashed_0002")])
1506 finally:
1507 recorder.record_unapplied("migrations", "0001_initial")
1508 recorder.record_unapplied("migrations", "0001_second")
1509 recorder.record_unapplied("migrations", "0001_squashed_0002")
1510
1511 @override_settings(
1512 MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed"}

Callers

nothing calls this directly

Calls 6

record_appliedMethod · 0.95
applied_migrationsMethod · 0.95
record_unappliedMethod · 0.95
MigrationRecorderClass · 0.90
call_commandFunction · 0.90
getvalueMethod · 0.45

Tested by

no test coverage detected