v0.2.0: CRM/ERP 系统升级 - 清理 .gitignore 并移除误提交的 venv/env/db 文件
- 更新 .gitignore:全面覆盖环境变量、数据库、日志、缓存、上传文件 - 移除误跟踪的 server/venv/、crm_data.db、.env 文件 - 新增 server/.env.example 模板 - 新增合同管理、利润核算、AI教练等功能模块 - 新增 Playwright e2e 测试套件 - 前后端多项功能升级和 bug 修复
This commit is contained in:
@@ -25,7 +25,10 @@ config = context.config
|
||||
db_url = os.getenv("DATABASE_URL", "")
|
||||
# Alembic 需要同步驱动,将 asyncpg 替换为 psycopg2
|
||||
sync_url = db_url.replace("+asyncpg", "")
|
||||
config.set_main_option("sqlalchemy.url", sync_url)
|
||||
# 宿主机执行 Alembic 时,host.docker.internal 不可达,替换为回环地址
|
||||
sync_url = sync_url.replace("host.docker.internal", "127.0.0.1")
|
||||
# configparser 把 % 当插值语法,需要转义为 %%
|
||||
config.set_main_option("sqlalchemy.url", sync_url.replace("%", "%%"))
|
||||
|
||||
# 日志配置
|
||||
if config.config_file_name is not None:
|
||||
@@ -33,7 +36,7 @@ if config.config_file_name is not None:
|
||||
|
||||
# 导入所有模型,确保 Alembic 能检测到所有表
|
||||
from app.models.base import Base
|
||||
from app.models import crm, erp, order, shipping, finance, ai, sys as sys_models
|
||||
from app.models import crm, erp, order, shipping, finance, ai, sys as sys_models, contract, cost
|
||||
|
||||
target_metadata = Base.metadata
|
||||
|
||||
@@ -61,8 +64,10 @@ async def run_async_migrations():
|
||||
"""在线迁移(异步引擎)"""
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
|
||||
# 宿主机执行 Alembic 时,host.docker.internal 不可达,替换为回环地址
|
||||
async_url = os.getenv("DATABASE_URL", "").replace("host.docker.internal", "127.0.0.1")
|
||||
connectable = create_async_engine(
|
||||
os.getenv("DATABASE_URL", ""),
|
||||
async_url,
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
async with connectable.connect() as connection:
|
||||
|
||||
Reference in New Issue
Block a user