优化更新

This commit is contained in:
2026-09-13 23:01:19 +08:00
parent 0c67b3e8b5
commit 23bd737b82
88 changed files with 2214 additions and 2503 deletions
@@ -113,18 +113,18 @@ Docker 部署时,`docker-compose.yml` 通过 `env_file: .env` 注入环境变
| DB_DRIVER | 数据库 | 依赖包 | 连接串格式 |
|-----------|--------|--------|-----------|
| mysql(默认) | MySQL 8.x | PyMySQL | `mysql+pymysql://user:pass@host:3306/db` |
| postgresql | PostgreSQL 14+ | psycopg[binary] | `postgresql+psycopg://user:pass@host:5432/db` |
| postgresql | PostgreSQL 14+ | psycopg2-binary | `postgresql+psycopg2://user:pass@host:5432/db` |
| mssql | SQL Server 2019+ | pymssql | `mssql+pymssql://user:pass@host:1433/db` |
| sqlite | SQLite 3 | 内置 | `sqlite:///path/to/db.sqlite3` |
| oracle | Oracle 12c+ | oracledb | `oracle+oracledb://user:pass@host:1521/db` |
:::tip 切换数据库后
切换数据库驱动后,需要重新初始化数据库结构。项目 Makefile 提供常用命令:
切换数据库驱动后,需要重新初始化数据库结构。常用命令:
```bash
make db-init # 初始化数据库(建库 + SQL 导入 + 补表 + flask db stamp)
make migrate-revision # 生成增量迁移脚本
make migrate-upgrade # 应用迁移
make migrate-stamp # 标记当前库已到基线
python scripts/setup_db.py # 初始化数据库(建库 + SQL 导入 + 补表 + flask db stamp)
flask db migrate # 生成增量迁移脚本
flask db upgrade # 应用迁移
flask db stamp head # 标记当前库已到基线
make db-migrate ARGS="..." # 跨库数据迁移
```
:::