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
+41 -2
View File
@@ -11,16 +11,56 @@
- 建立 pytest 基础设施
- 建立 Docker / Compose 基础骨架
- 建立 OpenAPI 导出脚本
- 迁入 `location recorder` 第一版
## 数据库配置现状
当前系统在配置层上已明确保留两个独立 SQLite DB 文件:
- `LOCATION_DATABASE_URL`
- `POO_DATABASE_URL`
当前阶段不打算把这两个数据库合并。
其中:
- `location` 模块已经实际接到 `LOCATION_DATABASE_URL`
- `poo` 目前只保留 `POO_DATABASE_URL` 配置占位,等待模块迁入
## 当前阶段未做内容
- 未迁移 TickTick 业务逻辑
- 未迁移 Home Assistant 业务逻辑
- 未迁移 poo records
- 未迁移 location / life trajectory
- 未实现真实 OAuth 流程
- 未做数据迁移
## Location recorder 说明
当前 Python 项目已经接入 `POST /location/record`,并对齐 legacy SQLite schema
```sql
CREATE TABLE location (
person TEXT NOT NULL,
datetime TEXT NOT NULL,
latitude REAL NOT NULL,
longitude REAL NOT NULL,
altitude REAL,
PRIMARY KEY (person, datetime)
);
```
当前已经补上最小 Alembic baseline / 接管策略:
- `location` 当前 schema 被视为 Alembic baseline
- 新数据库通过 `alembic upgrade head` 初始化
- 已有 legacy SQLite 数据库通过 `alembic stamp` 接管
- `PRAGMA user_version = 2` 仅保留为历史事实,不再作为新的主 migration 机制
详见:
- [location-recorder.md](location-recorder.md)
## 后续建议顺序
建议继续沿用既有迁移文档中的顺序:
@@ -37,4 +77,3 @@
- 不要把旧 Python 版本当作设计基线
- 不要重新引入 Notion 作为 Python 主系统能力
- 在迁业务模块时,优先补 contract tests