admin/sql/20260729_fix_user_empty_email.sql
2026-07-29 18:28:33 +08:00

13 lines
599 B
SQL
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.

-- 修复:微信注册无邮箱时曾写入 user.Email='',撞 uk_user_email 导致后续注册提示「邮箱已被占用」
-- 将空邮箱改为「客户编号@noemail.local」占位(与 CustomerContactHelper.ResolveRbacEmailOrPlaceholder 一致)
UPDATE `user` u
INNER JOIN `t_customer` c ON c.`UserId` = u.`userid`
SET u.`Email` = CONCAT(LOWER(TRIM(c.`CustomerCode`)), '@noemail.local')
WHERE u.`Email` IS NULL OR TRIM(u.`Email`) = '';
-- 无客户关联的残留空邮箱
UPDATE `user`
SET `Email` = CONCAT('u', `userid`, '@noemail.local')
WHERE `Email` IS NULL OR TRIM(`Email`) = '';