Files
ccdi/docs/reports/implementation/2026-04-22-staff-recruitment-collation-fix-implementation.md

35 lines
2.0 KiB
Markdown
Raw 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.
# 员工招聘列表排序规则冲突修复实施记录
## 基本信息
- 日期2026-04-22
- 范围:员工招聘列表后端查询与数据库排序规则修复
- 关联计划:`docs/plans/backend/2026-04-22-staff-recruitment-collation-fix-backend-implementation.md`
## 实施内容
- 修复 `CcdiStaffRecruitmentMapper.xml` 中招聘列表查询,对历史工作经历子查询的 `recruit_id` 聚合与关联显式指定 `utf8mb4_general_ci`,避免主表与子表排序规则不一致时在查询阶段报错。
- 修复 `2026-04-15-add-staff-recruitment-social-work-summary.sql`,为 `ccdi_staff_recruitment_work` 建表语句补齐 `COLLATE=utf8mb4_general_ci`,防止新环境建表时继承 MySQL 默认 `utf8mb4_0900_ai_ci`
- 新增 `2026-04-22-fix-staff-recruitment-work-collation.sql`,用于修复已有库中 `ccdi_staff_recruitment_work` 的存量排序规则。
- 更新 `2026-04-17-unify-all-table-collation-to-utf8mb4-general-ci.sql`,将 `ccdi_staff_recruitment_work` 纳入统一排序规则脚本。
## 根因结论
- `ccdi_staff_recruitment` 已统一为 `utf8mb4_general_ci`
- `ccdi_staff_recruitment_work` 的建表脚本未显式指定排序规则,且全库统一脚本遗漏该表,在 MySQL 8 默认排序规则为 `utf8mb4_0900_ai_ci` 的环境中会产生漂移。
- 招聘列表 SQL 使用 `w.recruit_id = r.recruit_id` 进行关联时触发不同排序规则比较,导致查询失败。
## 验证结果
- 后端编译:
`mvn -pl ccdi-info-collection -am compile`
结果PASS
- 数据库修复脚本:
`bin/mysql_utf8_exec.sh sql/migration/2026-04-22-fix-staff-recruitment-work-collation.sql`
结果:未执行(本次仅完成代码与脚本修复,待目标库执行)
## 后续执行说明
- 代码发布前,需先在目标库执行本次新增的排序规则修复脚本。
- 若目标库此前执行过 `2026-04-17-unify-all-table-collation-to-utf8mb4-general-ci.sql`,也仍需补执行本次新增脚本,因为旧脚本未覆盖 `ccdi_staff_recruitment_work`