Raise InconsistentMigrationHistory if any applied migrations have unapplied dependencies.
(self, connection)
| 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 | """ |