migrator.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:PyPlanet 作者: PyPlanet 项目源码 文件源码
def run_migration(self, name, app_label, app_module, save_migration=True):
        """
        Run + apply migration to the actual database.

        :param name: Name of migration.
        :param app_label: App label.
        :param app_module: App module path.
        :param save_migration: Save migration state?
        """
        from .models.migration import Migration
        mod = importlib.import_module('{}.migrations.{}'.format(app_module, name))

        try:
            with self.db.allow_sync():
                mod.upgrade(self.migrator)

                if save_migration:
                    Migration.create(
                        app=app_label,
                        name=name,
                        applied=True
                    )
        except Exception as e:
            logger.warning('Can\'t migrate {}.migrations.{}: {}'.format(app_module, name, str(e)))
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号