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)