Example #1
0
    def test_get_engine(self, mock_create_facade):
        facade = mock_create_facade.return_value
        facade.get_engine = mock.Mock(return_value='fake_engine')

        result = api.get_engine()
        mock_create_facade.assert_called_once_with()
        facade.get_engine.assert_called_once_with()
        self.assertEqual(result, 'fake_engine')
Example #2
0
    def test_get_engine(self, mock_create_facade):
        facade = mock_create_facade.return_value
        facade.get_engine = mock.Mock(return_value='fake_engine')

        result = api.get_engine()
        mock_create_facade.assert_called_once_with()
        facade.get_engine.assert_called_once_with()
        self.assertEqual(result, 'fake_engine')
Example #3
0
def version():
    """Current database version.

    :returns: Database version
    :type: string
    """
    engine = db_api.get_engine()
    with engine.connect() as conn:
        context = alembic_migration.MigrationContext.configure(conn)
        return context.get_current_revision()
Example #4
0
def version():
    """Current database version.

    :returns: Database version
    :type: string
    """
    engine = db_api.get_engine()
    with engine.connect() as conn:
        context = alembic_migration.MigrationContext.configure(conn)
        return context.get_current_revision()
Example #5
0
def version():
    """Current database version.

    :returns: Database version
    :type: string
    """
    engine = db_api.get_engine()
    with engine.connect() as conn:
        conf_table = getattr(CONF, 'version_table')
        utils.recheck_alembic_table(conn)
        context = alembic_migration.MigrationContext.configure(
            conn, opts={'version_table': conf_table})
        return context.get_current_revision()
Example #6
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context."""

    engine = db_api.get_engine()
    connection = engine.connect()
    target_metadata = db_models.RefStackBase.metadata
    context.configure(connection=connection, target_metadata=target_metadata)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
Example #7
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.
    """
    engine = db_api.get_engine()
    connection = engine.connect()
    target_metadata = db_models.RefStackBase.metadata
    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      version_table=getattr(CONF, 'version_table'))

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()