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


Python schema.changeset函数代码示例

本文整理汇总了Python中migrate.versioning.schema.changeset函数的典型用法代码示例。如果您正苦于以下问题:Python changeset函数的具体用法?Python changeset怎么用?Python changeset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了changeset函数的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 )
开发者ID:dbcls,项目名称:dbcls-galaxy,代码行数:7,代码来源:check.py

示例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)
开发者ID:allannss,项目名称:buildbot,代码行数:7,代码来源:model.py

示例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')
开发者ID:Aamirnadeem,项目名称:stock_analyzer,代码行数:29,代码来源:api.py

示例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
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:25,代码来源:check.py

示例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'
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:29,代码来源:api.py

示例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)
开发者ID:peterbe,项目名称:balrog,代码行数:11,代码来源:db.py

示例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)
开发者ID:buildbot,项目名称:highscore,代码行数:14,代码来源:model.py

示例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)
开发者ID:cturra,项目名称:balrog,代码行数:6,代码来源:db.py


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