当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.MigrationSchemaMissing方法代码示例

本文整理汇总了Python中django.db.migrations.exceptions.MigrationSchemaMissing方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.MigrationSchemaMissing方法的具体用法?Python exceptions.MigrationSchemaMissing怎么用?Python exceptions.MigrationSchemaMissing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.migrations.exceptions的用法示例。


在下文中一共展示了exceptions.MigrationSchemaMissing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_migrations

# 需要导入模块: from django.db.migrations import exceptions [as 别名]
# 或者: from django.db.migrations.exceptions import MigrationSchemaMissing [as 别名]
def check_migrations(self):
        """
        Checks to see if the set of migrations on disk matches the
        migrations in the database. Prints a warning if they don't match.
        """
        try:
            executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
        except ImproperlyConfigured:
            # No databases are configured (or the dummy one)
            return
        except MigrationSchemaMissing:
            self.stdout.write(self.style.NOTICE(
                "\nNot checking migrations as it is not possible to access/create the django_migrations table."
            ))
            return

        plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
        if plan:
            self.stdout.write(self.style.NOTICE(
                "\nYou have unapplied migrations; your app may not work properly until they are applied."
            ))
            self.stdout.write(self.style.NOTICE("Run 'python manage.py migrate' to apply them.\n"))

# Kept for backward compatibility 
开发者ID:wanzifa,项目名称:wanblog,代码行数:26,代码来源:runserver.py

示例2: check_migrations

# 需要导入模块: from django.db.migrations import exceptions [as 别名]
# 或者: from django.db.migrations.exceptions import MigrationSchemaMissing [as 别名]
def check_migrations(self):
        """
        Print a warning if the set of migrations on disk don't match the
        migrations in the database.
        """
        from django.db.migrations.executor import MigrationExecutor
        try:
            executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
        except ImproperlyConfigured:
            # No databases are configured (or the dummy one)
            return
        except MigrationSchemaMissing:
            self.stdout.write(self.style.NOTICE(
                "\nNot checking migrations as it is not possible to access/create the django_migrations table."
            ))
            return

        plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
        if plan:
            apps_waiting_migration = sorted(set(migration.app_label for migration, backwards in plan))
            self.stdout.write(
                self.style.NOTICE(
                    "\nYou have %(unpplied_migration_count)s unapplied migration(s). "
                    "Your project may not work properly until you apply the "
                    "migrations for app(s): %(apps_waiting_migration)s." % {
                        "unpplied_migration_count": len(plan),
                        "apps_waiting_migration": ", ".join(apps_waiting_migration),
                    }
                )
            )
            self.stdout.write(self.style.NOTICE("Run 'python manage.py migrate' to apply them.\n")) 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:33,代码来源:base.py


注:本文中的django.db.migrations.exceptions.MigrationSchemaMissing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。