• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.downgrade函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了downgrade函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: execute

    def execute(self, parsed_args):
        url = cfg.CONF['backend:powerdns'].database_connection

        if not os.path.exists(REPOSITORY):
            raise Exception('Migration Repository Not Found')

        try:
            target_version = int(parsed_args.to_version) \
                if parsed_args.to_version else None

            current_version = versioning_api.db_version(url=url,
                                                        repository=REPOSITORY)
        except DatabaseNotControlledError:
            raise Exception('PowerDNS database not yet initialized')

        LOG.info("Attempting to synchronize PowerDNS database from version "
                 "'%s' to '%s'",
                 current_version,
                 target_version if target_version is not None else "latest")

        if target_version and target_version < current_version:
            versioning_api.downgrade(url=url, repository=REPOSITORY,
                                     version=parsed_args.to_version)
        else:
            versioning_api.upgrade(url=url, repository=REPOSITORY,
                                   version=parsed_args.to_version)

        LOG.info('PowerDNS database synchronized successfully')
开发者ID:arjunpola,项目名称:designate,代码行数:28,代码来源:powerdns.py


示例2: sync

    def sync(self, version=None):
        url = cfg.CONF['storage:sqlalchemy'].database_connection

        if not os.path.exists(REPOSITORY):
            raise Exception('Migration Repository Not Found')

        try:
            target_version = int(version) if version else None

            current_version = versioning_api.db_version(url=url,
                                                        repository=REPOSITORY)
        except DatabaseNotControlledError:
            raise Exception('Database not yet initialized')

        LOG.info("Attempting to synchronize database from version "
                 "'%s' to '%s'",
                 current_version,
                 target_version if target_version is not None else "latest")

        if target_version and target_version < current_version:
            versioning_api.downgrade(url=url, repository=REPOSITORY,
                                     version=version)
        else:
            versioning_api.upgrade(url=url, repository=REPOSITORY,
                                   version=version)

        LOG.info('Database synchronized successfully')
开发者ID:gvnkd,项目名称:designate,代码行数:27,代码来源:database.py


示例3: __init__

 def __init__(self, file, repository, echoresults):
     
     #for backward compatibelity
     if re.match('^\w+://', file) == None:
         file = 'sqlite:///'+file   
     
     self.version = 2
     self.dbfile = file
     self.repository = repository
     
  
     
     #migrate code
     try:
         dbversion = api.db_version(file, self.repository)
         #print dbversion
     except :
         dbversion = 0
         api.version_control(file, self.repository, dbversion)
     
     if dbversion < self.version:
         api.upgrade(file, self.repository, self.version)
     elif  dbversion > self.version:
         api.downgrade(file, self.repository, self.version)
     
     engine = create_engine(file , echo=False)#edit by hassan : echoresults to True
     
     metadata = Base.metadata
     metadata.create_all(engine)
 
     Session = sessionmaker(engine)
     self.session = Session()            
开发者ID:AhmadHamzeei,项目名称:Amir-Accounting,代码行数:32,代码来源:__init__.py


示例4: execute

    def execute(self, parsed_args):
        url = cfg.CONF['storage:sqlalchemy'].database_connection

        if not os.path.exists(REPOSITORY):
            raise Exception('Migration Respository Not Found')

        try:
            target_version = int(parsed_args.to_version) \
                if parsed_args.to_version else None

            current_version = versioning_api.db_version(url=url,
                                                        repository=REPOSITORY)
        except DatabaseNotControlledError:
            raise Exception('Database not yet initialized')

        LOG.info("Attempting to synchronize database from version '%s' to '%s'"
                 % (current_version, target_version))

        if target_version and target_version < current_version:
            versioning_api.downgrade(url=url, repository=REPOSITORY,
                                     version=parsed_args.to_version)
        else:
            versioning_api.upgrade(url=url, repository=REPOSITORY,
                                   version=parsed_args.to_version)

        LOG.info('Database synchronized sucessfully')
开发者ID:appliedcode,项目名称:moniker,代码行数:26,代码来源:database.py


示例5: downgrade_db

def downgrade_db(*opts):
    '''
    Downgrades the Database 1 rev.
    '''
    v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    api.downgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, v - 1)
    print 'Current database version: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, 
                                                            SQLALCHEMY_MIGRATE_REPO))
开发者ID:irishjack,项目名称:Concord,代码行数:8,代码来源:dbmngr.py


示例6: db_downgrade

def db_downgrade(version):
    """Downgrade the database"""
    v1 = get_db_version()
    migrate_api.downgrade(url=db_url, repository=db_repo, version=version)
    v2 = get_db_version()

    if v1 == v2:
        print 'No changes made.'
    else:
        print 'Downgraded: %s ... %s' % (v1, v2)
开发者ID:Ms2ger,项目名称:standup,代码行数:10,代码来源:manage.py


示例7: downgraddb

def downgraddb():
    v = api.db_version(Config.SQLALCHEMY_DATABASE_URI,
                       Config.SQLALCHEMY_MIGRATE_REPO)

    api.downgrade(Config.SQLALCHEMY_DATABASE_URI,
                  Config.SQLALCHEMY_MIGRATE_REPO, v - 1)
    v = api.db_version(Config.SQLALCHEMY_DATABASE_URI,
                       Config.SQLALCHEMY_MIGRATE_REPO)

    print 'Current database version: ' + str(v)
开发者ID:YanshuoH,项目名称:whats-today,代码行数:10,代码来源:manager.py


示例8: downgrade_db

def downgrade_db(v):
    """downgrade database schema to specified version"""
    from_version = db_version(url=db, repository=repo)
    to_version = int(v)

    print("Downgrading db from version %d to %d. " % (from_version, to_version))
    print("Schema upgrade ... ")
    downgrade(url=db, repository=repo, version=v)
    print("Data upgrade ... ")
    datamigrations.run_downgrade_scripts(app, from_version, to_version)
    print("Done!")
开发者ID:jkossen,项目名称:imposter,代码行数:11,代码来源:dbmanage.py


示例9: _migrate_down

    def _migrate_down(self, engine, version, with_data=False):
        migration_api.downgrade(engine, TestMigrations.REPOSITORY, version)
        self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY))

        # NOTE(sirp): `version` is what we're downgrading to (i.e. the 'target'
        # version). So if we have any downgrade checks, they need to be run for
        # the previous (higher numbered) migration.
        if with_data:
            post_downgrade = getattr(self, "_post_downgrade_%03d" % (version + 1), None)
            if post_downgrade:
                post_downgrade(engine)
开发者ID:jacobwagner,项目名称:glance,代码行数:11,代码来源:test_migrations.py


示例10: _downgradeDB

def _downgradeDB(expectedVersion, dryrun):
    if not dryrun:
        api.downgrade(SQLALCHEMY_DATABASE_URI,
                      SQLALCHEMY_MIGRATE_REPO,
                      expectedVersion)
    
    print 'Current database version: ' + \
          str(api.db_version(SQLALCHEMY_DATABASE_URI,
                         SQLALCHEMY_MIGRATE_REPO))
    if dryrun:
        print 'Dryrun'
        print '\tNew database version will be: ' + str(expectedVersion)
开发者ID:FYJen,项目名称:website,代码行数:12,代码来源:db_script.py


示例11: db_downgrade

def db_downgrade(version=None):
    # This is used to downgrade the database schema to a certain version or to one version before.
    # If you know exactly the version you wish to use then you can directly downgrade to that version.
    if not version:
        current_version = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
        downgrade_version = current_version - 1
    else:
        downgrade_version = version
    api.downgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, downgrade_version)

    print 'Database downgrade completed!'
    print 'Current database version: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO))
开发者ID:widoyo,项目名称:EmeraldBox,代码行数:12,代码来源:box.py


示例12: rollback

def rollback(count):
    if (rollbacks > v) or (rollbacks < 0):
        print "Invalid rollbacks count. Current version is %d." % v
        rollbacks = int(raw_input("Input valid count:"))
        rollback(rollbacks)
    else:
        api.downgrade(SQLALCHEMY_DATABASE_URI,
                      SQLALCHEMY_MIGRATE_REPO,
                      v - count)
        print ('Current database version: ' + 
               str(api.db_version(SQLALCHEMY_DATABASE_URI,
                                  SQLALCHEMY_MIGRATE_REPO)))
开发者ID:viddik13,项目名称:my-microblog,代码行数:12,代码来源:db_upgrade.py


示例13: downgrade

def downgrade(args):
    """
    Restores the database one previous version, run multiple times to go
    back multiple versions if needed.
    """

    # Get the configruation
    config = get_config()
    DB_URI = config.DATABASE_URI
    M_REPO = config.MIGRATIONS

    v = api.db_version(DB_URI, M_REPO)
    api.downgrade(DB_URI, M_REPO, v - 1)
    v = api.db_version(DB_URI, M_REPO)
    return "Current database version: %i" % v
开发者ID:eleventhend,项目名称:jobs-report,代码行数:15,代码来源:elmr-admin.py


示例14: db_sync

def db_sync(abs_path, version=None, init_version=0):
    """Upgrade or downgrade a database.

    Function runs the upgrade() or downgrade() functions in change scripts.

    :param abs_path:     Absolute path to migrate repository.
    :param version:      Database will upgrade/downgrade until this version.
                         If None - database will update to the latest
                         available version.
    :param init_version: Initial database version
    """
    if version is not None:
        try:
            version = int(version)
        except ValueError:
            raise exception.DbMigrationError(
                message=_("version should be an integer"))

    current_version = db_version(abs_path, init_version)
    repository = _find_migrate_repo(abs_path)
    if version is None or version > current_version:
        return versioning_api.upgrade(get_engine(), repository, version)
    else:
        return versioning_api.downgrade(get_engine(), repository,
                                        version)
开发者ID:kickstandproject,项目名称:ripcord,代码行数:25,代码来源:migration.py


示例15: db_sync

def db_sync(engine, version=None, init_version=INIT_VERSION):
    """Upgrade or downgrade a database.

    Function runs the upgrade() or downgrade() functions in change scripts.

    :param engine:       SQLAlchemy engine instance for a given database
    :param version:      Database will upgrade/downgrade until this version.
                         If None - database will update to the latest
                         available version.
    :param init_version: Initial database version
    """

    if version is not None:
        try:
            version = int(version)
        except ValueError:
            raise exception.DbMigrationError(
                message='version should be an integer')

    current_version = db_version(engine, init_version)
    repository = _find_migrate_repo()
    if version is None or version > current_version:
        return versioning_api.upgrade(engine, repository, version)
    else:
        return versioning_api.downgrade(engine, repository, version)
开发者ID:DKILLER123,项目名称:seedbox,代码行数:25,代码来源:migration.py


示例16: db_sync

def db_sync(engine, abs_path, version=None, init_version=0, sanity_check=True):
    """Upgrade or downgrade a database.

    Function runs the upgrade() or downgrade() functions in change scripts.

    :param engine:       SQLAlchemy engine instance for a given database
    :param abs_path:     Absolute path to migrate repository.
    :param version:      Database will upgrade/downgrade until this version.
                         If None - database will update to the latest
                         available version.
    :param init_version: Initial database version
    :param sanity_check: Require schema sanity checking for all tables
    """

    if version is not None:
        try:
            version = int(version)
        except ValueError:
            raise exception.DbMigrationError(
                message=_("version should be an integer"))

    current_version = db_version(engine, abs_path, init_version)
    repository = _find_migrate_repo(abs_path)
    if sanity_check:
        _db_schema_sanity_check(engine)
    if version is None or version > current_version:
        return versioning_api.upgrade(engine, repository, version)
    else:
        return versioning_api.downgrade(engine, repository,
                                        version)
开发者ID:malor,项目名称:oslo.db,代码行数:30,代码来源:migration.py


示例17: downgradedb

def downgradedb():
    """ Downgrades the database from the current to the previous
        version contained in the SQLAlchemy-migrate repository.
    """

    # Obtain Current Version
    ver = api.db_version(app.config['SQLALCHEMY_DATABASE_URI'],
                         app.config['SQLALCHEMY_MIGRATE_REPO'])

    # Downgrade Database To Previous Revision
    api.downgrade(app.config['SQLALCHEMY_DATABASE_URI'],
                  app.config['SQLALCHEMY_MIGRATE_REPO'], ver-1)

    # Obtain & Display Current Version
    ver = api.db_version(app.config['SQLALCHEMY_DATABASE_URI'],
                         app.config['SQLALCHEMY_MIGRATE_REPO'])
    print("Current database version: " + str(ver))
开发者ID:ikinsella,项目名称:squall,代码行数:17,代码来源:manage.py


示例18: downgrade

def downgrade(version):
    """Downgrade the database's current migration level."""
    db_version()  # Ensure db is under migration control
    repo_path = get_migrate_repo_path()
    sql_connection = CFG.db.sql_connection
    logger.info("Downgrading %(sql_connection)s to version %(version)s" %
                locals())
    return versioning_api.downgrade(sql_connection, repo_path, version)
开发者ID:pperezrubio,项目名称:Tempo,代码行数:8,代码来源:migration.py


示例19: migrate_repository

def migrate_repository(version, current_version, repo_path):
    if version is None or version > current_version:
        result = versioning_api.upgrade(CONF.sql.connection,
                                        repo_path, version)
    else:
        result = versioning_api.downgrade(
            CONF.sql.connection, repo_path, version)
    return result
开发者ID:aboumawada,项目名称:keystone,代码行数:8,代码来源:migration.py


示例20: do_db

 def do_db(self, line=''):
     args = line.split()
     action = args[0]
     if not action in self.db_actions:
         self.help_db()
         return 1
     self._register_config()
     import shakespeare.model as model
     import shakespeare
     migrate_repository = 'shakespeare/migration/'
     if action == 'create':
         model.repo.create_db()
     elif action == 'clean':
         model.repo.clean_db()
     elif action == 'rebuild':
         model.repo.rebuild_db()
     elif action == 'upgrade':
         version = None
         if len(args) > 1:
             version = args[1]
         import migrate.versioning.exceptions
         import migrate.versioning.api
         import migrate.versioning.api as mig
         try:
             mig.version_control(model.meta.engine.url, migrate_repository)
         except migrate.versioning.exceptions.DatabaseAlreadyControlledError:
             pass
         mig.upgrade(model.meta.engine.url, migrate_repository,
                 version=version)
     elif action == 'downgrade':
         if len(args) < 2:
             print 'You need to supply a version to downgrade to'
             return 1
         version = args[1]
         import migrate.versioning.api
         import migrate.versioning.api as mig
         mig.downgrade(model.meta.engine.url, migrate_repository,
                 version=version)
     elif action.startswith('init_'):
         modname = action.strip()[5:]
         mod = __import__(modname+'.cli', fromlist='cli')
         mod.LoadTexts.load_texts()
     else:
         print self.help_db()
开发者ID:deeban25,项目名称:shakespeare,代码行数:44,代码来源:cli.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.make_update_script_for_model函数代码示例发布时间:2022-05-27
下一篇:
Python api.db_version函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap