From 405d158660a549c8a08bef66f157561aaca42641 Mon Sep 17 00:00:00 2001 From: VMIS Developer Date: Sun, 15 Mar 2026 18:34:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(alembic):=20env.py=20=E5=84=AA=E5=85=88?= =?UTF-8?q?=E8=AE=80=E5=8F=96=20DATABASE=5FURL=20=E7=92=B0=E5=A2=83?= =?UTF-8?q?=E8=AE=8A=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- backend/alembic/env.py | 5 +++++ 1 file changed, 5 insertions(+) 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