43 lines
1.2 KiB
Markdown
43 lines
1.2 KiB
Markdown
# game_self_game_robots 迁移说明
|
|
|
|
## 目标
|
|
|
|
把旧 `hyapp_game.game_self_game_robots` 的机器人池迁移到 `hyapp_robot.robot_game_robots`,不删除旧库旧表。
|
|
|
|
## 迁移规则
|
|
|
|
- 来源表:`hyapp_game.game_self_game_robots`
|
|
- 目标表:`hyapp_robot.robot_game_robots`
|
|
- 聚合维度:`app_code + user_id`
|
|
- 目标 `game_id`:写入 `dice`,只作为兼容字段使用
|
|
- 状态规则:同一用户任意旧行是 `active`,目标状态就是 `active`;否则为 `disabled`
|
|
- 使用统计:`last_used_at_ms` 和 `used_count` 取旧行最大值
|
|
|
|
## 幂等
|
|
|
|
迁移成功后写入:
|
|
|
|
```sql
|
|
hyapp_robot.robot_service_migrations
|
|
```
|
|
|
|
迁移键:
|
|
|
|
```text
|
|
game_robots_from_game_self_game_robots_v1
|
|
```
|
|
|
|
标记存在后,后续启动不会再次从旧表覆盖新表。
|
|
|
|
## 回滚
|
|
|
|
旧表不删除、不重命名、不清空。需要回滚时,可以让旧版本继续读取 `hyapp_game.game_self_game_robots`。
|
|
|
|
## 新逻辑
|
|
|
|
迁移完成后:
|
|
|
|
- game-service 通过 `robot-service` gRPC 读写游戏机器人池。
|
|
- robot-service 只读写 `hyapp_robot.robot_game_robots`。
|
|
- 旧 `game_self_game_robots` 只保留给历史排查和回滚,不再作为新逻辑来源。
|