MCPcopy
hub / github.com/django/django / check_consistent_history

Method check_consistent_history

django/db/migrations/loader.py:344–370  ·  view source on GitHub ↗

Raise InconsistentMigrationHistory if any applied migrations have unapplied dependencies.

(self, connection)

Source from the content-addressed store, hash-verified

342 self.graph.ensure_not_cyclic()
343
344 def check_consistent_history(self, connection):
345 """
346 Raise InconsistentMigrationHistory if any applied migrations have
347 unapplied dependencies.
348 """
349 recorder = MigrationRecorder(connection)
350 applied = recorder.applied_migrations()
351 for migration in applied:
352 # If the migration is unknown, skip it.
353 if migration not in self.graph.nodes:
354 continue
355 for parent in self.graph.node_map[migration].parents:
356 if parent not in applied:
357 # Skip unapplied squashed migrations that have all of their
358 # `replaces` applied.
359 if self.all_replaced_applied(parent.key, applied):
360 continue
361 raise InconsistentMigrationHistory(
362 "Migration {}.{} is applied before its dependency "
363 "{}.{} on database '{}'.".format(
364 migration[0],
365 migration[1],
366 parent[0],
367 parent[1],
368 connection.alias,
369 )
370 )
371
372 def all_replaced_applied(self, migration_key, applied):
373 """

Callers 4

handleMethod · 0.95
handleMethod · 0.80

Calls 5

applied_migrationsMethod · 0.95
all_replaced_appliedMethod · 0.95
MigrationRecorderClass · 0.90
formatMethod · 0.45