Migrate location recorder and refine db config

This commit is contained in:
2026-04-19 21:39:23 +02:00
parent 31390882ef
commit 32cc6847fd
19 changed files with 507 additions and 31 deletions
+21 -6
View File
@@ -10,6 +10,7 @@
- 环境变量配置体系
- SQLite + SQLAlchemy + Alembic 基础设施
- 极简 server-side templates
- location recorder 第一版迁移
- pytest 测试基础
- OpenAPI 导出脚本
- Docker / Compose 基础骨架
@@ -19,7 +20,6 @@
- TickTick 业务逻辑迁移
- Home Assistant 业务逻辑迁移
- poo records 业务迁移
- location / life trajectory 业务迁移
- Notion 模块
Notion 在 Go 版本中仍然存在,但已被明确视为 legacy / removed scope,不进入新的 Python 系统目标。
@@ -30,6 +30,20 @@ Notion 在 Go 版本中仍然存在,但已被明确视为 legacy / removed sco
- `legacy/go-backend/helper/`
- `legacy/go-backend/.github/workflows/`
## 当前配置现实
当前系统仍然是两个独立的 SQLite 数据库文件,而不是单一数据库:
- `location` 模块使用自己的 DB 文件
- `poo` 模块未来也将使用自己的 DB 文件
当前阶段明确不借这次重构把两个 DB 合并。配置层已经显式反映这一点:
- `LOCATION_DATABASE_URL`
- `POO_DATABASE_URL`
目前真正接入的是 `location` 对应的数据库;`poo` 先保留配置占位,等模块迁入时再接上。
## 当前目录
Python 骨架的主要目录如下:
@@ -100,9 +114,10 @@ uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
## 数据库与 Alembic
当前默认数据库使用 SQLite
当前默认使用 SQLite,但要明确区分两个数据库文件:
- 默认数据库地址`sqlite:///./data/app.db`
- Location DB`sqlite:///./data/locationRecorder.db`
- Poo DB`sqlite:///./data/pooRecorder.db`
- 数据目录:`./data/`
初始化 migration 环境后,可继续添加模型并生成迁移:
@@ -112,7 +127,7 @@ alembic revision --autogenerate -m "init tables"
alembic upgrade head
```
这一轮尚未引入业务表,因此 Alembic 目前主要是基础设施就绪状态
当前 Alembic 只接管 `location` 这条链路;`poo` 相关数据库与 migration 还没有迁入
## 运行测试
@@ -163,15 +178,15 @@ SQLite 持久化目录:
## 后续迁移建议
后续可以在当前骨架上逐步迁移这些模块:
后续可以在当前骨架上继续迁移这些模块:
- TickTick integration
- Home Assistant integration
- poo records
- location / life trajectory
建议继续参考:
- [当前系统盘点](docs/current-system-inventory.md)
- [Python 重构方案](docs/python-rewrite-plan.md)
- [迁移风险清单](docs/migration-risks.md)
- [Location Recorder 接管说明](docs/location-recorder.md)