def version_control(version=None): """ Place a database under migration control """ sql_connection = CONF.sql_connection try: _version_control(version) except versioning_exceptions.DatabaseAlreadyControlledError, e: msg = (_("database is already under migration control")) raise exception.DatabaseMigrationError(msg)
def version_control(conf, version=None): """ Place a database under migration control :param conf: conf dict """ sql_connection = conf.sql_connection try: _version_control(conf, version) except versioning_exceptions.DatabaseAlreadyControlledError, e: msg = (_("database '%(sql_connection)s' is already under migration " "control") % locals()) raise exception.DatabaseMigrationError(msg)
def db_version(): """ Return the database's current migration number :retval version number """ repo_path = get_migrate_repo_path() sql_connection = CONF.sql_connection try: return versioning_api.db_version(sql_connection, repo_path) except versioning_exceptions.DatabaseNotControlledError, e: msg = (_("database is not under migration control")) raise exception.DatabaseMigrationError(msg)
def version_control(options): """ Place a database under migration control :param options: options dict """ sql_connection = options['sql_connection'] try: _version_control(options) except versioning_exceptions.DatabaseAlreadyControlledError, e: msg = (_("database '%(sql_connection)s' is already under migration " "control") % locals()) raise exception.DatabaseMigrationError(msg)
def db_sync(version=None, current_version=None): """ Place a database under migration control and perform an upgrade :retval version number """ sql_connection = CONF.sql_connection try: _version_control(current_version) except versioning_exceptions.DatabaseAlreadyControlledError, e: if current_version is not None: msg = (_("database '%(sql_connection)s' is already under " "migration control") % locals()) raise exception.DatabaseMigrationError(msg)
def db_version(conf): """ Return the database's current migration number :param conf: conf dict :retval version number """ repo_path = get_migrate_repo_path() sql_connection = conf.sql_connection try: return versioning_api.db_version(sql_connection, repo_path) except versioning_exceptions.DatabaseNotControlledError, e: msg = (_("database '%(sql_connection)s' is not under " "migration control") % locals()) raise exception.DatabaseMigrationError(msg)