fix(alembic): env.py 優先讀取 DATABASE_URL 環境變數
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user