From 80343d3782922cad0b1b7c3845bed4da4e929fad Mon Sep 17 00:00:00 2001 From: Jack Levy Date: Sun, 15 Mar 2026 19:05:01 -0400 Subject: [PATCH] fix: alembic reads DB URL from config.py (secrets file) not hardcoded alembic.ini Authored by: Jack Levy --- backend/alembic/env.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/alembic/env.py b/backend/alembic/env.py index 7d0c4be..3a0b430 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -10,8 +10,14 @@ import app.models # noqa: F401 — registers all models with Base.metadata config = context.config -# Override sqlalchemy.url from environment if set +# Override sqlalchemy.url — prefer env var, then config.py (which reads secrets file) sync_url = os.environ.get("SYNC_DATABASE_URL") +if not sync_url: + try: + from app.config import settings as app_settings + sync_url = app_settings.SYNC_DATABASE_URL + except Exception: + pass if sync_url: config.set_main_option("sqlalchemy.url", sync_url)