當前位置: 首頁>>代碼示例>>Python>>正文


Python api.version_control方法代碼示例

本文整理匯總了Python中migrate.versioning.api.version_control方法的典型用法代碼示例。如果您正苦於以下問題:Python api.version_control方法的具體用法?Python api.version_control怎麽用?Python api.version_control使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在migrate.versioning.api的用法示例。


在下文中一共展示了api.version_control方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: db_version_control

# 需要導入模塊: from migrate.versioning import api [as 別名]
# 或者: from migrate.versioning.api import version_control [as 別名]
def db_version_control(engine, abs_path, version=None):
    """Mark a database as under this repository's version control.

    Once a database is under version control, schema changes should
    only be done via change scripts in this repository.

    :param engine:  SQLAlchemy engine instance for a given database
    :param abs_path: Absolute path to migrate repository
    :param version:  Initial database version
    """
    repository = _find_migrate_repo(abs_path)

    try:
        versioning_api.version_control(engine, repository, version)
    except versioning_exceptions.InvalidVersionError as ex:
        raise exception.DBMigrationError("Invalid version : %s" % ex)
    except versioning_exceptions.DatabaseAlreadyControlledError:
        raise exception.DBMigrationError("Database is already controlled.")

    return version 
開發者ID:openstack,項目名稱:oslo.db,代碼行數:22,代碼來源:migration.py

示例2: db_version_control

# 需要導入模塊: from migrate.versioning import api [as 別名]
# 或者: from migrate.versioning.api import version_control [as 別名]
def db_version_control(version=None):
    repository = _find_migrate_repo()
    versioning_api.version_control(get_engine(), repository, version)
    return version 
開發者ID:openstack,項目名稱:ec2-api,代碼行數:6,代碼來源:migration.py

示例3: setup_migration_version_control

# 需要導入模塊: from migrate.versioning import api [as 別名]
# 或者: from migrate.versioning.api import version_control [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 
開發者ID:italia,項目名稱:daf-recipes,代碼行數:11,代碼來源:__init__.py

示例4: __init__

# 需要導入模塊: from migrate.versioning import api [as 別名]
# 或者: from migrate.versioning.api import version_control [as 別名]
def __init__(self, file, repository, echoresults):

        # for backward compatibelity
        if re.match('^\w+://', file) == None:
            file = 'sqlite:///'+file

        self.version = 3
        self.dbfile = file
        self.repository = repository

        # migrate code
        try:
            dbversion = api.db_version(file, self.repository)
            logging.debug('Current DB version: "%d"' % dbversion)
        except:  # if no previous database found => first installing
            dbversion = 0
            api.version_control(file, self.repository, dbversion)

        versioningDone = False

        if dbversion < self.version:
            api.upgrade(file, self.repository, self.version)
            versioningDone = True
        elif dbversion > self.version:
            api.downgrade(file, self.repository, self.version)
            versioningDone = True

        # edit by hassan : echoresults to True
        engine = create_engine(file, echo=echoresults)
        self.engine = engine

        metadata = Base.metadata
        metadata.create_all(engine)

        Session = sessionmaker(engine)
        self.session = Session()
        if versioningDone:
            self.rebuild_nested_set(0, 0) 
開發者ID:Jooyeshgar,項目名稱:amir,代碼行數:40,代碼來源:__init__.py

示例5: migrate

# 需要導入模塊: from migrate.versioning import api [as 別名]
# 或者: from migrate.versioning.api import version_control [as 別名]
def migrate(connection_string: str = None):
    folder = os.path.dirname(__file__)
    connection_string = connection_string or SA_CONNECTION_STRING
    try:
        api.version_control(url=connection_string, repository=folder)
    except DatabaseAlreadyControlledError:
        pass

    api.upgrade(url=connection_string, repository=folder) 
開發者ID:lightforever,項目名稱:mlcomp,代碼行數:11,代碼來源:manage.py


注:本文中的migrate.versioning.api.version_control方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。