From 4460131b71715685b6f64e9a02c47be6b9f8a064 Mon Sep 17 00:00:00 2001 From: TradeMate Dev Date: Thu, 14 May 2026 10:24:50 +0800 Subject: [PATCH] fix: make alembic use env var DATABASE_URL instead of hardcoded dev db --- backend/alembic.ini | 3 ++- backend/alembic/env.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/alembic.ini b/backend/alembic.ini index d910f09..1d6a20d 100644 --- a/backend/alembic.ini +++ b/backend/alembic.ini @@ -2,7 +2,8 @@ script_location = alembic prepend_sys_path = . version_path_separator = os -sqlalchemy.url = postgresql+asyncpg://tradmate:tradmate@localhost:5432/tradmate +# 生产环境数据库 +sqlalchemy.url = postgresql+asyncpg://foreign_trade:dWFNi67nHNbPbjmP@localhost:5432/foreign_trade [loggers] keys = root,sqlalchemy,alembic diff --git a/backend/alembic/env.py b/backend/alembic/env.py index f42644b..386f6c9 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -13,9 +13,11 @@ if config.config_file_name is not None: fileConfig(config.config_file_name) from app.database import Base +from app.config import settings from app.models import User, Product, Customer, Conversation, Message, Quotation, QuotationItem, CorpusEntry, Team, TeamMember, UsageLog, Notification, Feedback, Subscription, PreferenceAnalysis, MarketingEffect, Device, FollowupStrategy, FollowupLog, SystemConfig target_metadata = Base.metadata +config.set_main_option("sqlalchemy.url", settings.DATABASE_URL) def run_migrations_offline() -> None: