-- 修复员工基础表和员工家庭关系表字符集排序规则
-- 问题: ccdi_staff_fmy_relation.person_id (utf8mb4_general_ci) 与 ccdi_base_staff.id_card (utf8mb4_unicode_ci) 字符集不一致
-- 解决方案: 统一为 utf8mb4_general_ci
-- 执行时间: 2026-02-09

USE
`ruoyi-vue-pro`;

-- 修改 ccdi_base_staff 表的 id_card 字段字符集，统一为 utf8mb4_general_ci
ALTER TABLE `ccdi_base_staff`
    MODIFY COLUMN `id_card` VARCHAR (100) DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT '身份证号';

-- 验证修改
SELECT TABLE_NAME,
       COLUMN_NAME,
       CHARACTER_SET_NAME,
       COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'ruoyi-vue-pro'
  AND TABLE_NAME IN ('ccdi_staff_fmy_relation', 'ccdi_base_staff')
  AND COLUMN_NAME IN ('person_id', 'id_card')
ORDER BY TABLE_NAME, COLUMN_NAME;

-- 说明: 执行后两个表的字符集应该都显示为 utf8mb4_general_ci
