Files
i/README.md
wsh5485 d7dab31f19 docs: add table prefix migration task (21 CarLog tables)
按用户决定「i系统内的carlog数据库表要加carlog_前缀」:
- 之前方案是「留给将来加第二个子系统时」, 现在提前做
- 新增 Task 2.8 表前缀迁移 (含 5 个子节 + review checklist)
- DEV-PLAN.md:
  - 关键决策表「本阶段不做」→「本阶段做」
  - 加 Task 2.8: 备份 + migration 020 + 改 server SQL + reset-all.js + 验证
  - 加 §6.2.11 表前缀迁移 review checklist (10 项)
  - 「不做的事」: 删掉表前缀
  - 「完成定义」: 加 Task 2.8
- ARCHITECTURE.md:
  - §3 决策表同步
  - §7 W2 改成完整 RENAME TABLE 21 张 + 备份警告
  - 删掉过时的 db.js tableName helper 建议
- README.md:
  - 决策表同步
  - 实施路线按 Phase 1 / 2 / 2.8 / 3 重新分组
  - 删掉「暂不做: CarLog 表前缀」

迁移策略:
- 21 张 CarLog 业务表加 carlog_ 前缀 (含 carlog_settings)
- 5 张共享表不动 (users / login_attempts / auth_locks / schema_migrations / 平台表)
- 改前必做 mysqldump 备份 (RENAME 是 DDL 不能事务回滚)
- 直接改 SQL (不加 helper 函数, 20 张表工作量可控)
- sed \\b word boundary 安全替换 (列了完整 21 张表清单, 不动共享表 4 张)
2026-06-20 23:06:12 +08:00

106 lines
6.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# i — 个人生活操作系统
一个**单 Vue + 单 Express + 单 MySQL** 的生活操作系统平台,按子系统分代码目录和 API 路径,永远单用户。
第一个子系统是 [CarLog](https://gitea.img2img.com/wsh5485/CarLog)(洗车管理系统),将来可能加:健身、阅读、健康等(**用户还没决定下一子系统,本阶段不做**)。
## 架构核心
```
┌────────────────────────────────────────────────────────┐
│ Vue SPA (一个壳子) │
│ │
│ ┌──────────────────────────────────────────────────────┐│
│ │ 总设置 / 子系统管理 / Dashboard (平台层) ││
│ └──────────────────────────────────────────────────────┘│
│ │
│ ┌──────────────────────────────────────────────────────┐│
│ │ 🚗 CarLog | 未来子系统 ││
│ └──────────────────────────────────────────────────────┘│
│ │
└────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────┐
│ Express (一个进程) │
│ ├── /api/platform/* (总设置 / 子系统管理 / Dashboard) │
│ ├── /api/carlog/* (CarLog 子系统, 全部带前缀) │
│ └── /api/{future}/* (将来加的子系统) │
└────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────┐
│ MySQL @ 162.14.110.130:33306 / carlog │
│ │
│ 平台表 (无前缀): │
│ subsystems / platform_settings │
│ │
│ 子系统表 (有前缀): │
│ carlog_vehicles / carlog_wash_records / ... │
│ │
│ (将来加): │
│ fitness_workouts / fitness_plans / ... │
│ reading_books / reading_notes / ... │
└────────────────────────────────────────────────────────┘
```
## 物理隔离靠什么
| 维度 | 做法 |
|---|---|
| 数据 | 表前缀 `{subsystem}_*`(同一 DB 内;CarLog 已加 `carlog_` 前缀,将来加 fitness/reading 直接走 `fitness_*` / `reading_*` |
| 路由 | 子系统自己的路径空间(`/api/carlog/*` |
| 代码 | 子系统独立目录(`server/src/subsystems/{name}/``client/src/views/subsystems/{name}/` |
| 设置 | 每个子系统有自己的 settings schemaJSON Schema,存 `platform_settings` 表,key 前缀 `{name}.*` |
| 菜单 | 每个子系统在 `subsystems` 表注册,平台层根据 `category` 分组渲染左侧导航 |
**没有** JWT / SSO / iframe / 6 端点协议 / 独立 DB — 那些都是过度设计。
## 实施路线
### 当前阶段(Phase 1 平台基座 + Phase 2 CarLog 子系统化 + 表前缀迁移)
**Phase 1 平台基座**
- [ ] `server/migrations/019_platform.sql`subsystems + platform_settings 表 + seed CarLog
- [ ] `server/src/routes/platform/{subsystems,settings,dashboard}.js`
- [ ] `client/src/views/Platform/{GlobalSettings,SubsystemSettings,Subsystems}.vue`
- [ ] `client/src/stores/platform.js` + `AppLayout.vue` 元数据驱动菜单
- [ ] 测试(12-20 个平台测试)
**Phase 2 CarLog 子系统化**
- [ ] CarLog 代码移到 `server/src/subsystems/carlog/`13 个路由文件)
- [ ] CarLog 路由全部 mount 到 `/api/carlog/*`(不再是 `/api/vehicles`
- [ ] CarLog 前端 view 移到 `client/src/views/subsystems/carlog/`
- [ ] 前端 API 改用 `carlogApi` helper(自动加 `/api/carlog/` 前缀)
**Phase 2.8 表前缀迁移**(用户决定)
- [ ] `server/migrations/020_carlog_prefix.sql` — 21 张 CarLog 表加 `carlog_` 前缀
- [ ] **改前先 mysqldump 备份**
- [ ] 13 个路由文件 + reset-all.js SQL 加前缀
- [ ] 数据完整性验证(行数不变)
**Phase 3 验证**
- [ ] 手动 E2E 14 步 + DB 数据完整 + 备份清理
### 暂不做(用户没决定)
- ❌ 加第二个子系统(健身 / 阅读 / 任何)
- ❌ 跨子系统 dashboard widget
- ❌ 多用户 / RBAC / 多租户
## 路线原则
- **永远单用户**:不要 RBAC / 多租户 / 权限 scope
- **一个进程一个 SPA**:不分部署不分 iframe
- **元数据驱动 UI**subsystem 的 settings_schema / nav_items 走 JSON,不硬编码
- **物理目录隔离**:subsystem 代码独立目录,加新子系统不会乱碰现有代码
- **永远向后兼容**:CarLog 的现有功能不破
详细见 [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) / [docs/DEV-PLAN.md](docs/DEV-PLAN.md) / [docs/UI-STYLE.md](docs/UI-STYLE.md)(UI 规范 — 平台层 100% 复用 CarLog UI)。
## Git 仓库
- 仓库:https://gitea.img2img.com/wsh5485/i.git
- 平台:Gitea
- 推送:osxkeychain 自动记住 token
- 推送:osxkeychain 自动记住 token