Print a warning if the set of migrations on disk don't match the migrations in the database.
(self)
| 583 | self.stdout.write(msg) |
| 584 | |
| 585 | def check_migrations(self): |
| 586 | """ |
| 587 | Print a warning if the set of migrations on disk don't match the |
| 588 | migrations in the database. |
| 589 | """ |
| 590 | from django.db.migrations.executor import MigrationExecutor |
| 591 | |
| 592 | try: |
| 593 | executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) |
| 594 | except ImproperlyConfigured: |
| 595 | # No databases are configured (or the dummy one) |
| 596 | return |
| 597 | |
| 598 | plan = executor.migration_plan(executor.loader.graph.leaf_nodes()) |
| 599 | if plan: |
| 600 | apps_waiting_migration = sorted( |
| 601 | {migration.app_label for migration, backwards in plan} |
| 602 | ) |
| 603 | self.stdout.write( |
| 604 | self.style.NOTICE( |
| 605 | "\nYou have %(unapplied_migration_count)s unapplied migration(s). " |
| 606 | "Your project may not work properly until you apply the " |
| 607 | "migrations for app(s): %(apps_waiting_migration)s." |
| 608 | % { |
| 609 | "unapplied_migration_count": len(plan), |
| 610 | "apps_waiting_migration": ", ".join(apps_waiting_migration), |
| 611 | } |
| 612 | ) |
| 613 | ) |
| 614 | self.stdout.write( |
| 615 | self.style.NOTICE("Run 'python manage.py migrate' to apply them.") |
| 616 | ) |
| 617 | |
| 618 | def handle(self, *args, **options): |
| 619 | """ |
no test coverage detected