test db setup
This commit is contained in:
+9
-5
@@ -5,6 +5,7 @@ from dotenv import load_dotenv
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
from alembic import context
|
||||
from src.db import get_set_engine
|
||||
from src.models_db import BaseModelDb
|
||||
|
||||
load_dotenv() # reads .env into os.environ
|
||||
@@ -64,11 +65,14 @@ def run_migrations_online() -> None:
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
if get_set_engine() is not None:
|
||||
connectable = get_set_engine()
|
||||
else:
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
|
||||
Reference in New Issue
Block a user