This commit is contained in:
2025-09-15 12:42:57 +08:00
parent 310b80fac3
commit 9c3e11fa50
15 changed files with 263 additions and 61 deletions

View File

@@ -1,3 +1,24 @@
-- 统一历史数据:将 biz_module.assignee 迁移为用户ID字符串
-- 注意:仅对 status='1' 或 '2' 且 assignee 非数字的历史记录进行转换
-- 先将 assignee 为用户名的,更新为对应的 user_id
UPDATE biz_module m
LEFT JOIN sys_user u ON m.assignee = u.user_name
SET m.assignee = CAST(u.user_id AS CHAR)
WHERE m.assignee IS NOT NULL
AND m.assignee <> ''
AND m.assignee REGEXP '^[0-9]+$' = 0
AND u.user_id IS NOT NULL;
-- 若 assignee 是昵称(而非用户名),尝试通过昵称匹配
UPDATE biz_module m
LEFT JOIN sys_user u ON m.assignee = u.nick_name
SET m.assignee = CAST(u.user_id AS CHAR)
WHERE m.assignee IS NOT NULL
AND m.assignee <> ''
AND m.assignee REGEXP '^[0-9]+$' = 0
AND u.user_id IS NOT NULL;
-- 约束:未来只允许用 ID 存储 assignee可在业务层保证不在库层加约束
/*
Navicat Premium Data Transfer