2 Commits
Author SHA1 Message Date
ChristandClaude Opus 4.8 fb83aacb8b refactor(db): 阶段C - Postgres migration 补全
- migrations/postgres/ 8 个文件改为 Postgres 方言:
  BIGSERIAL、原生 BOOLEAN、TEXT 主键、ON CONFLICT DO NOTHING/UPDATE、
  "key" 双引号处理保留字
- 跳过 SQLite 历史遗留列(与 MySQL 版一致)
- 00005 ws_messages 空操作(00001 已建)

至此三套数据库 migration 全部就位,业务 SQL 通过方言适配器统一处理。
SQLite 全测试通过,MySQL/PG 待真实实例验证。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 13:02:30 +08:00
ChristandClaude Opus 4.8 0fa5d6617c refactor(db): 阶段A - driver 抽象 + SQLite 保持工作
- db.Open 改为接受 URL(sqlite:// mysql:// postgres://),返回 (db, dialect, err)
- 向后兼容:不含 scheme 的路径仍按 SQLite 文件处理
- migration 移到 migrations/sqlite/ 子目录,embed 包含三个方言目录
- Migrate 按方言选择子目录 + goose dialect
- Store 加 Dialect 字段,NewStore(db, dialect)
- cmd/server 加 -db-url 和 DATABASE_URL 环境变量(优先级:env > -db-url > -db)
- cmd/init-admin 同步支持 URL
- 新增依赖 pgx/v5、go-sql-driver/mysql
- mysql/postgres migration 目录暂为 SQLite 副本占位,阶段B/C 替换
- 所有测试调用方更新为新签名

验证:现有测试全过(SQLite 回归),SQLite 行为不变

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 12:35:01 +08:00