Files
DP/Server/migrations/README.md

797 B

数据库迁移说明

当前项目保留两套迁移策略:

  1. Alembic 适用于正式环境和多人协作,是推荐方案。
  2. app/db.py -> ensure_migrations() 仅作为本地 SQLite 开发时的兜底补列逻辑。

推荐流程

cd Server
.venv\Scripts\python -m alembic upgrade head

新增模型字段后生成迁移:

cd Server
.venv\Scripts\python -m alembic revision --autogenerate -m "describe_change"

注意事项:

  • Server/alembic/env.py 已按 Server 目录固定加载配置,不依赖当前启动目录。
  • 自动生成迁移前,先确认 app/models/ 中新增模型已被 Alembic 导入。
  • 如果只是本机 SQLite 调试,项目仍会在启动时走一次轻量补列;但不要把它当作正式迁移方案。