You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
digital-rmb-backend/.workbuddy/memory/2026-10-10.md

22 lines
1.9 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 2026-10-10
- SSO 登录真实库报错 `Data truncated for column 'platform_user_id'`(非 401,401 已修好):
根因是**运行库 schema 漂移**,不是代码 bug。dev 环境 `spring.sql.init.mode=never`,`schema.sql` 不自动执行,
`platform_user_snapshot.platform_user_id`(及 auth_login_exchange_code / auth_refresh_token 的platform_user_id)
在真 MySQL 库里被建成比 VARCHAR(36) 更窄或数值型;代码写入本地 user_id(UUID,36 字符)装不下即截断。
H2 测试库按 schema.sql 的 VARCHAR(36) 建表,故全部测试通过、只在真库报错。
- **最终方案(用户拍板:快照表不需要)**:不再使用 `platform_user_snapshot`,把学校/学院/专业/班级
统一并进 `sys_user` 主表。已落地:
- schema.sql(main+test)给 `sys_user` 加 `college_id/college_name/major_id/major_name` 4 列,
并删除 `platform_user_snapshot` 建表与种子数据;
- `UserEntity`、`UserMapper.selectActiveByStudentId` 同步加列;
- `LocalSsoAccountService` 去掉 `upsertSnapshot`,改把 college/major 写进 `sys_user`;
`UserController.success` 与 `CurrentUserService` 改从 `sys_user` 读(不再读快照);
- 删除 `PlatformUserSnapshotEntity` / `PlatformUserSnapshotMapper`;
- 新增 `db/manual/sys_user_profile_upgrade.sql`(ADD 4 列 + DROP `platform_user_snapshot`)。
- **真库 `118.31.7.2/digital_rmb` 已执行**:`sys_user` 加了 4 列、`platform_user_snapshot` 已 DROP。
- 测试:`LocalSsoAccountServiceTest`/`UserControllerTest`/`CurrentUserAndLogoutTest`/
`PlatformTokenVerifierTest`/`PlatformSsoControllerTest`/`PlatformIntegrationConfigTest` 共 15 用例全过。
- 经验:此类"测试过、真库截断"优先怀疑运行库列定义与 schema.sql 不一致(本项目 dev 不跑 schema.sql),
直接给手动 ALTER 脚本比改代码更准。