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


Python api.version方法代码示例

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


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

示例1: upgrade_db

# 需要导入模块: from migrate.versioning import api [as 别名]
# 或者: from migrate.versioning.api import version [as 别名]
def upgrade_db(self, version=None):
        '''Upgrade db using sqlalchemy migrations.

        @param version: version to upgrade to (if None upgrade to latest)
        '''
        assert meta.engine.name in ('postgres', 'postgresql'), \
            'Database migration - only Postgresql engine supported (not %s).' \
                % meta.engine.name
        import migrate.versioning.api as mig
        self.setup_migration_version_control()
        version_before = mig.db_version(self.metadata.bind, self.migrate_repository)
        mig.upgrade(self.metadata.bind, self.migrate_repository, version=version)
        version_after = mig.db_version(self.metadata.bind, self.migrate_repository)
        if version_after != version_before:
            log.info('CKAN database version upgraded: %s -> %s', version_before, version_after)
        else:
            log.info('CKAN database version remains as: %s', version_after)

        ##this prints the diffs in a readable format
        ##import pprint
        ##from migrate.versioning.schemadiff import getDiffOfModelAgainstDatabase
        ##pprint.pprint(getDiffOfModelAgainstDatabase(self.metadata, self.metadata.bind).colDiffs) 
开发者ID:italia,项目名称:daf-recipes,代码行数:24,代码来源:__init__.py

示例2: version

# 需要导入模块: from migrate.versioning import api [as 别名]
# 或者: from migrate.versioning.api import version [as 别名]
def version(self):
        current = get_manager().version()
        latest = versioning_api.version(repository=REPOSITORY).value
        print("Current: %s Latest: %s" % (current, latest)) 
开发者ID:openstack,项目名称:designate,代码行数:6,代码来源:database.py

示例3: init_model

# 需要导入模块: from migrate.versioning import api [as 别名]
# 或者: from migrate.versioning.api import version [as 别名]
def init_model(engine):
    '''Call me before using any of the tables or classes in the model'''
    meta.Session.remove()
    meta.Session.configure(bind=engine)
    meta.create_local_session.configure(bind=engine)
    meta.engine = engine
    meta.metadata.bind = engine
    # sqlalchemy migrate version table
    import sqlalchemy.exc
    try:
        global version_table
        version_table = Table('migrate_version', meta.metadata, autoload=True)
    except sqlalchemy.exc.NoSuchTableError:
        pass 
开发者ID:italia,项目名称:daf-recipes,代码行数:16,代码来源:__init__.py

示例4: latest_migration_version

# 需要导入模块: from migrate.versioning import api [as 别名]
# 或者: from migrate.versioning.api import version [as 别名]
def latest_migration_version(self):
        import migrate.versioning.api as mig
        version = mig.version(self.migrate_repository)
        return version 
开发者ID:italia,项目名称:daf-recipes,代码行数:6,代码来源:__init__.py

示例5: setup_migration_version_control

# 需要导入模块: from migrate.versioning import api [as 别名]
# 或者: from migrate.versioning.api import version [as 别名]
def setup_migration_version_control(self, version=None):
        import migrate.exceptions
        import migrate.versioning.api as mig
        # set up db version control (if not already)
        try:
            mig.version_control(self.metadata.bind,
                    self.migrate_repository, version)
        except migrate.exceptions.DatabaseAlreadyControlledError:
            pass 
开发者ID:italia,项目名称:daf-recipes,代码行数:11,代码来源:__init__.py


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