def sync_database_to_version(extension=None, version=None):
    if not extension:
        abs_path = find_migrate_repo()
        init_version = migrate_repo.DB_INIT_VERSION
    else:
        init_version = 0
        try:
            package_name = '.'.join((contrib.__name__, extension))
            package = importutils.import_module(package_name)
        except ImportError:
            raise ImportError(_("%s extension does not exist.")
                              % package_name)
        try:
            abs_path = find_migrate_repo(package)
            try:
                migration.db_version_control(sql.get_engine(), abs_path)
            # Register the repo with the version control API
            # If it already knows about the repo, it will throw
            # an exception that we can safely ignore
            except exceptions.DatabaseAlreadyControlledError:
                pass
        except exception.MigrationNotProvided as e:
            print(e)
            sys.exit(1)
    migration.db_sync(sql.get_engine(), abs_path, version=version,
                      init_version=init_version)
 def setup_database(self):
     super(OAuth1Tests, self).setup_database()
     package_name = '.'.join((contrib.__name__, self.EXTENSION_NAME))
     package = importutils.import_module(package_name)
     abs_path = migration_helpers.find_migrate_repo(package)
     migration.db_version_control(sql.get_engine(), abs_path)
     migration.db_sync(sql.get_engine(), abs_path)
Exemple #3
0
 def setup_database(self):
     super(TestExtensionCase, self).setup_database()
     package_name = '.'.join((contrib.__name__, self.EXTENSION_NAME))
     package = importutils.import_module(package_name)
     abs_path = migration_helpers.find_migrate_repo(package)
     migration.db_version_control(abs_path)
     migration.db_sync(abs_path)
Exemple #4
0
 def main():
     version = CONF.command.version
     extension = CONF.command.extension
     if not extension:
         abs_path = migration_helpers.find_migrate_repo()
     else:
         try:
             package_name = '.'.join((contrib.__name__, extension))
             package = importutils.import_module(package_name)
         except ImportError:
             raise ImportError(
                 _("%s extension does not exist.") % package_name)
         try:
             abs_path = migration_helpers.find_migrate_repo(package)
             try:
                 migration.db_version_control(abs_path)
             # Register the repo with the version control API
             # If it already knows about the repo, it will throw
             # an exception that we can safely ignore
             except exceptions.DatabaseAlreadyControlledError:
                 pass
         except exception.MigrationNotProvided as e:
             print(e)
             exit(0)
     migration.db_sync(abs_path, version=version)
Exemple #5
0
 def setup_database(self):
     super(OAuth1Tests, self).setup_database()
     package_name = '.'.join((contrib.__name__, self.EXTENSION_NAME))
     package = importutils.import_module(package_name)
     abs_path = migration_helpers.find_migrate_repo(package)
     migration.db_version_control(abs_path)
     migration.db_sync(abs_path)
 def setup_database(self):
     super(TestExtensionCase, self).setup_database()
     package_name = '.'.join((contrib.__name__, self.EXTENSION_NAME))
     package = importutils.import_module(package_name)
     abs_path = migration_helpers.find_migrate_repo(package)
     migration.db_version_control(sql.get_engine(), abs_path)
     migration.db_sync(sql.get_engine(), abs_path)
Exemple #7
0
 def main():
     version = CONF.command.version
     extension = CONF.command.extension
     if not extension:
         abs_path = migration_helpers.find_migrate_repo()
     else:
         try:
             package_name = '.'.join((contrib.__name__, extension))
             package = importutils.import_module(package_name)
         except ImportError:
             raise ImportError(_("%s extension does not exist.")
                               % package_name)
         try:
             abs_path = migration_helpers.find_migrate_repo(package)
             try:
                 migration.db_version_control(abs_path)
             # Register the repo with the version control API
             # If it already knows about the repo, it will throw
             # an exception that we can safely ignore
             except exceptions.DatabaseAlreadyControlledError:
                 pass
         except exception.MigrationNotProvided as e:
             print(e)
             exit(0)
     migration.db_sync(abs_path, version=version)
 def setup_database(self):
     self.conf_files = super(TestExtensionCase, self).config_files()
     self.conf_files.append(
         tests.dirs.tests('test_associate_project_endpoint_extension.conf'))
     super(TestExtensionCase, self).setup_database()
     package_name = '.'.join((contrib.__name__, self.EXTENSION_NAME))
     package = importutils.import_module(package_name)
     abs_path = migration_helpers.find_migrate_repo(package)
     migration.db_version_control(abs_path)
     migration.db_sync(abs_path)
Exemple #9
0
def sync_database_to_version(extension=None, version=None):
    if not extension:
        abs_path = find_migrate_repo()
    else:
        try:
            package_name = '.'.join((contrib.__name__, extension))
            package = importutils.import_module(package_name)
        except ImportError:
            raise ImportError(_("%s extension does not exist.")
                              % package_name)
        try:
            abs_path = find_migrate_repo(package)
            try:
                migration.db_version_control(sql.get_engine(), abs_path)
            # Register the repo with the version control API
            # If it already knows about the repo, it will throw
            # an exception that we can safely ignore
            except exceptions.DatabaseAlreadyControlledError:
                pass
        except exception.MigrationNotProvided as e:
            print(e)
            sys.exit(1)

    engine = sql.get_engine()
    try:
        migration.db_sync(engine, abs_path, version=version)
    except ValueError:
        # NOTE(morganfainberg): ValueError is raised from the sanity check (
        # verifies that tables are utf8 under mysql). The region table was not
        # initially built with InnoDB and utf8 as part of the table arguments
        # when the migration was initially created. Bug #1334779 is a scenario
        # where the deployer can get wedged, unable to upgrade or downgrade.
        # This is a workaround to "fix" that table if we're under MySQL.
        if (not extension and engine.name == 'mysql' and
                six.text_type(get_db_version()) == '37'):
            _fix_migration_37(engine)
            # Try the migration a second time now that we've done the
            # un-wedge work.
            migration.db_sync(engine, abs_path, version=version)
        else:
            raise
Exemple #10
0
def db_version_control(version=None):
    return migration.db_version_control(_repo_path(), version=version)