All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 4m57s
- 新增数据库迁移文件添加last_login_time字段 - 在登录逻辑中更新最后登录时间 - 添加FindActiveSubscribesByUserIds方法查询用户订阅状态 - 在用户列表接口中聚合最后登录时间和会员状态信息 - 更新相关API定义和模型结构 - 修复迁移文件版本号冲突问题 - 移除omitempty标签确保字段始终返回
26 lines
1.1 KiB
Markdown
26 lines
1.1 KiB
Markdown
# 迁移文件重复问题修复计划
|
|
|
|
## 问题分析
|
|
根据终端日志报错 `panic: failed to init driver with path database: duplicate migration file: 02121_apple_iap_transactions.down.sql`,系统启动失败的原因是存在**重复的迁移版本号**。
|
|
|
|
在 `initialize/migrate/database/` 目录下,存在两个版本号相同的迁移文件:
|
|
1. `02121_add_user_last_login_time.up.sql` (我们刚刚创建的)
|
|
2. `02121_apple_iap_transactions.up.sql` (已存在的)
|
|
|
|
由于 `golang-migrate` 要求版本号必须唯一,这两个文件都使用了 `02121` 前缀,导致冲突。
|
|
|
|
## 解决方案
|
|
将我们新创建的 `add_user_last_login_time` 迁移文件的版本号递增为 `02122`。
|
|
|
|
## 实施步骤
|
|
1. **重命名迁移文件**:
|
|
- `02121_add_user_last_login_time.up.sql` -> `02122_add_user_last_login_time.up.sql`
|
|
- `02121_add_user_last_login_time.down.sql` -> `02122_add_user_last_login_time.down.sql`
|
|
|
|
2. **验证**:
|
|
- 确认目录下不再有重复前缀的文件。
|
|
- 建议用户重新运行程序。
|
|
|
|
## 补充说明
|
|
此操作仅涉及文件重命名,不修改文件内容,风险极低。
|