本文整理汇总了Python中migrate.versioning.schema.runchange函数的典型用法代码示例。如果您正苦于以下问题:Python runchange函数的具体用法?Python runchange怎么用?Python runchange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runchange函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_to_current_version
def migrate_to_current_version( engine, schema ):
# Changes to get to current version
changeset = schema.changeset( None )
for ver, change in changeset:
nextver = ver + changeset.step
log.info( 'Migrating %s -> %s... ' % ( ver, nextver ) )
schema.runchange( ver, change, changeset.step )
示例2: upgrade
def upgrade(engine):
schema = migrate.versioning.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)
示例3: _migrate
def _migrate(url, repository, version, upgrade, err, **opts):
engine = opts.pop('engine')
url = str(engine.url)
schema = ControlledSchema(engine, repository)
version = _migrate_version(schema, version, upgrade, err)
changeset = schema.changeset(version)
for ver, change in changeset:
nextver = ver + changeset.step
log.info('%s -> %s... ', ver, nextver)
if opts.get('preview_sql'):
if isinstance(change, PythonScript):
log.info(change.preview_sql(url, changeset.step, **opts))
elif isinstance(change, SqlScript):
log.info(change.source())
elif opts.get('preview_py'):
if not isinstance(change, PythonScript):
raise exceptions.UsageError("Python source can be only displayed"
" for python migration files")
source_ver = max(ver, nextver)
module = schema.repository.version(source_ver).script().module
funcname = upgrade and "upgrade" or "downgrade"
func = getattr(module, funcname)
log.info(inspect.getsource(func))
else:
schema.runchange(ver, change, changeset.step)
log.info('done')
示例4: migrate_to_current_version
def migrate_to_current_version(engine, schema):
# Changes to get to current version
changeset = schema.changeset(None)
for ver, change in changeset:
nextver = ver + changeset.step
log.info('Migrating %s -> %s... ' % (ver, nextver))
old_stdout = sys.stdout
class FakeStdout(object):
def __init__(self):
self.buffer = []
def write(self, s):
self.buffer.append(s)
def flush(self):
pass
sys.stdout = FakeStdout()
try:
schema.runchange(ver, change, changeset.step)
finally:
for message in "".join(sys.stdout.buffer).split("\n"):
log.info(message)
sys.stdout = old_stdout
示例5: _migrate
def _migrate(url, repository, version, upgrade, err, **opts):
engine = construct_engine(url, **opts)
schema = ControlledSchema(engine, repository)
version = _migrate_version(schema, version, upgrade, err)
changeset = schema.changeset(version)
for ver, change in changeset:
nextver = ver + changeset.step
print '%s -> %s... ' % (ver, nextver)
if opts.get('preview_sql'):
if isinstance(change, PythonScript):
print change.preview_sql(url, changeset.step, **opts)
elif isinstance(change, SqlScript):
print change.source()
elif opts.get('preview_py'):
source_ver = max(ver, nextver)
module = schema.repository.version(source_ver).script().module
funcname = upgrade and "upgrade" or "downgrade"
func = getattr(module, funcname)
if isinstance(change, PythonScript):
print inspect.getsource(func)
else:
raise UsageError("Python source can be only displayed"
" for python migration files")
else:
schema.runchange(ver, change, changeset.step)
print 'done'
示例6: upgrade
def upgrade(self, version=None):
# This method was taken from Buildbot: https://github.com/buildbot/buildbot/blob/87108ec4088dc7fd5394ac3c1d0bd3b465300d92/master/buildbot/db/model.py#L455
# http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=100
# means we cannot use the migrate.versioning.api module. So these
# methods perform similar wrapping functions to what is done by the API
# functions, but without disposing of the engine.
schema = migrate.versioning.schema.ControlledSchema(self.engine, self.migrate_repo)
changeset = schema.changeset(version)
for step, change in changeset:
self.log.debug('migrating schema version %s -> %d' % (step, step + 1))
schema.runchange(step, change, 1)
示例7: thd
def thd(engine):
try:
schema = migrate.versioning.schema.ControlledSchema(engine,
self.repo_path)
except exceptions.DatabaseNotControlledError:
migrate.versioning.schema.ControlledSchema.create(engine,
self.repo_path, None)
schema = migrate.versioning.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)
示例8: downgrade
def downgrade(self, version):
schema = migrate.versioning.schema.ControlledSchema(self.engine, self.migrate_repo)
changeset = schema.changeset(version)
for step, change in changeset:
self.log.debug('migrating schema version %s -> %d' % (step, step - 1))
schema.runchange(step, change, -1)