I need to specify different databases for different configurations, one for running migrations, one for units tests, one for Jenkins...
Here is what I currently do:
alembic/env.py:
def run_migrations_online():
engine = create_engine(
create_app('settings.yaml').config['DATABASE_URL'],
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
That works for regular migrations, but not for tests. What is the standard way to do this?