當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。