本文整理汇总了Python中migrate.versioning.schema.ControlledSchema类的典型用法代码示例。如果您正苦于以下问题:Python ControlledSchema类的具体用法?Python ControlledSchema怎么用?Python ControlledSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ControlledSchema类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: upgrade
def upgrade(engine):
schema = ControlledSchema(engine, self.repo_path)
changeset = schema.changeset(None)
for version, change in changeset:
log.msg('migrating schema version %s -> %d'
% (version, version + 1))
schema.runchange(version, change, 1)
开发者ID:aminembarki,项目名称:buildbot,代码行数:7,代码来源:model.py
示例2: upgrade
def upgrade(engine):
schema = ControlledSchema(engine, self.repo_path)
changeset = schema.changeset(None)
with sautils.withoutSqliteForeignKeys(engine):
for version, change in changeset:
log.msg('migrating schema version %s -> %d'
% (version, version + 1))
schema.runchange(version, change, 1)
开发者ID:595796726,项目名称:buildbot,代码行数:8,代码来源:model.py
示例3: version_control
def version_control(engine, version=None):
ControlledSchema.create(engine, self.repo_path, version)
开发者ID:aminembarki,项目名称:buildbot,代码行数:2,代码来源:model.py
示例4: main
def main():
import camelot
import logging
logging.basicConfig(level=logging.INFO)
#logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
parser = CommandOptionParser(usage=usage,
description=description,
version=camelot.__version__)
(_options, args) = parser.parse_args()
if not args:
parser.print_help()
elif args[0]=='console':
setup_model()
sh = Shell()
sh.interact()
elif args[0]=='schema_display':
setup_model()
schema_display()
elif args[0] in ('version_control', 'db_version', 'version', 'upgrade'):
import settings
from migrate.versioning.repository import Repository
from migrate.versioning.schema import ControlledSchema
from migrate.versioning.exceptions import DatabaseNotControlledError
from sqlalchemy.exceptions import NoSuchTableError
migrate_engine = settings.ENGINE()
repository = Repository(settings.REPOSITORY)
schema = None
try:
schema = ControlledSchema(migrate_engine, repository)
except (NoSuchTableError, DatabaseNotControlledError):
print 'database not yet under version control, putting it under version_control first.'
if args[0]=='version_control' or schema is None:
migrate_connection = migrate_engine.connect()
transaction = migrate_connection.begin()
try:
schema = ControlledSchema.create(migrate_engine, repository)
transaction.commit()
except:
transaction.rollback()
raise
finally:
migrate_connection.close()
print 'database was put under version control'
if schema:
if args[0]=='db_version':
print schema.version
elif args[0]=='version':
print repository.latest
elif args[0]=='upgrade':
migrate_connection = migrate_engine.connect()
if len(args)>=2:
version = int(args[1])
else:
version = repository.latest
#
# perform each upgrade step in a separate transaction, since
# one upgrade might depend on an other being fully executed
#
try:
if schema.version == version:
print 'database is allready at requested version'
if schema.version <= version:
step = 1
else:
step = -1
for i in range(schema.version+step, version+step, step):
transaction = migrate_connection.begin()
try:
schema.upgrade(i)
transaction.commit()
if step==1:
print 'upgrade %s'%i
else:
print 'downgrade %s'%i
except:
transaction.rollback()
raise
finally:
migrate_connection.close()
else:
parser.print_help()
开发者ID:kurtraschke,项目名称:camelot,代码行数:81,代码来源:camelot_manage.py
注:本文中的migrate.versioning.schema.ControlledSchema类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论