예제 #1
0
def get_migration_manager(repo_path, url, init_version=None):
    migration_config = {
        'migration_repo_path': repo_path,
        'db_url': url,
        'init_version': init_version,
    }
    return manager.MigrationManager(migration_config)
예제 #2
0
def get_manager(pool_target):
    connection = pool_target.options.get('connection', None)

    migration_config = {
        'migration_repo_path': REPOSITORY,
        'db_url': connection}

    return migration_manager.MigrationManager(migration_config)
예제 #3
0
def get_manager(pool_target_id):
    pool_target_options = CONF['pool_target:%s' % pool_target_id].options
    connection = pool_target_options['connection']

    migration_config = {
        'migration_repo_path': REPOSITORY,
        'db_url': connection
    }
    return migration_manager.MigrationManager(migration_config)
예제 #4
0
 def setUp(self):
     self.migration_config = {'alembic_ini_path': '.',
                              'migrate_repo_path': '.',
                              'db_url': 'sqlite://'}
     engine = sqlalchemy.create_engine(self.migration_config['db_url'])
     self.migration_manager = manager.MigrationManager(
         self.migration_config, engine)
     self.ext = mock.Mock()
     self.ext.obj.version = mock.Mock(return_value=0)
     self.migration_manager._manager.extensions = [self.ext]
     super(TestMigrationManager, self).setUp()
예제 #5
0
def get_manager():
    alembic_path = os.path.join(os.path.dirname(__file__), '..', 'db',
                                'sqlalchemy', 'alembic.ini')
    migrate_path = os.path.join(os.path.dirname(__file__), '..', 'db',
                                'sqlalchemy', 'alembic')
    migration_config = {
        'alembic_ini_path': alembic_path,
        'alembic_repo_path': migrate_path,
        'db_url': CONF.database.connection
    }
    return migration_manager.MigrationManager(migration_config)
예제 #6
0
def db_migration(ctx):
    alembic_path = os.path.abspath(
        os.path.join(os.path.dirname(migration.__file__),
                     'alembic.ini'))
    migrate_path = os.path.abspath(os.path.dirname(
        alembic_migrations.__file__))
    migration_config = {'alembic_ini_path': alembic_path,
                        'alembic_repo_path': migrate_path}
    ctx.obj['manager'] = manager.MigrationManager(migration_config,
                                                  engine=api.get_engine())
    config.setup_logging()
예제 #7
0
def get_manager():
    global _MANAGER
    if not _MANAGER:
        alembic_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'alembic.ini'))
        migrate_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'alembic'))
        migration_config = {'alembic_ini_path': alembic_path,
                            'alembic_repo_path': migrate_path,
                            'db_url': cfg.CONF.database.connection}
        _MANAGER = manager.MigrationManager(migration_config)

    return _MANAGER
예제 #8
0
def get_manager(conf):
    alembic_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'alembic.ini'))
    migrate_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'alembic'))
    migration_config = {
        'alembic_ini_path': alembic_path,
        'alembic_repo_path': migrate_path,
        'db_url': conf.database.connection
    }
    mgr = manager.MigrationManager(migration_config)

    context.nabu_config = conf
    return mgr
예제 #9
0
파일: db_manage.py 프로젝트: wenchma/magnum
def get_manager():
    if cfg.CONF.database.connection is None:
        raise ValueError(
            'Database connection not set in /etc/magnum/magnum.conf')

    alembic_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__),
                     '..', 'db', 'sqlalchemy', 'alembic.ini'))
    migrate_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__),
                     '..', 'db', 'sqlalchemy', 'alembic'))
    migration_config = {'alembic_ini_path': alembic_path,
                        'alembic_repo_path': migrate_path,
                        'db_url': CONF.database.connection}
    return manager.MigrationManager(migration_config)
예제 #10
0
 def setUp(self):
     self.migration_config = {'alembic_ini_path': '.',
                              'migrate_repo_path': '.',
                              'db_url': 'sqlite://'}
     engine = sqlalchemy.create_engine(self.migration_config['db_url'])
     self.migration_manager = manager.MigrationManager(
         self.migration_config, engine)
     self.first_ext = MockWithCmp()
     self.first_ext.obj.order = 1
     self.first_ext.obj.upgrade.return_value = 100
     self.first_ext.obj.downgrade.return_value = 0
     self.second_ext = MockWithCmp()
     self.second_ext.obj.order = 2
     self.second_ext.obj.upgrade.return_value = 200
     self.second_ext.obj.downgrade.return_value = 100
     self.migration_manager._manager.extensions = [self.first_ext,
                                                   self.second_ext]
     super(TestMigrationMultipleExtensions, self).setUp()
예제 #11
0
 def setUp(self):
     self.migration_config = {
         'alembic_ini_path': '.',
         'migrate_repo_path': '.',
         'db_url': 'sqlite://'
     }
     self.migration_manager = manager.MigrationManager(
         self.migration_config)
     self.first_ext = MockWithCmp()
     self.first_ext.obj.order = 1
     self.first_ext.obj.upgrade.return_value = 100
     self.first_ext.obj.downgrade.return_value = 0
     self.second_ext = MockWithCmp()
     self.second_ext.obj.order = 2
     self.second_ext.obj.upgrade.return_value = 200
     self.second_ext.obj.downgrade.return_value = 100
     self.migration_manager._manager.extensions = [
         self.first_ext, self.second_ext
     ]
     super(TestMigrationRightOrder, self).setUp()
예제 #12
0
def get_manager():
    migration_config = {
        'migration_repo_path': REPOSITORY,
        'db_url': CONF['backend:powerdns'].connection
    }
    return migration_manager.MigrationManager(migration_config)