diff --git a/backend/alembic/env.py b/backend/alembic/env.py index f762caa..1f1a416 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -1,3 +1,4 @@ +import os from logging.config import fileConfig from alembic import context @@ -9,6 +10,10 @@ config = context.config fileConfig(config.config_file_name) target_metadata = Base.metadata +# Use SYNC_DATABASE_URL env var if set, otherwise fall back to alembic.ini +if os.getenv("SYNC_DATABASE_URL"): + config.set_main_option("sqlalchemy.url", os.getenv("SYNC_DATABASE_URL")) + def run_migrations_offline(): url = config.get_main_option("sqlalchemy.url")