fix: alembic reads DB URL from config.py (secrets file) not hardcoded alembic.ini
Authored by: Jack Levy
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user