diff --git a/backend/alembic/env.py b/backend/alembic/env.py index aa44fc4..c2f876a 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -16,6 +16,11 @@ config = context.config if config.config_file_name is not None: fileConfig(config.config_file_name) +# 優先使用環境變數 DATABASE_URL(正式環境部署用) +_db_url = os.environ.get("DATABASE_URL") +if _db_url: + config.set_main_option("sqlalchemy.url", _db_url) + target_metadata = Base.metadata