本文整理匯總了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)
示例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))
示例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
示例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
示例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