This commit is contained in:
2025-12-13 17:44:18 +08:00
commit c7a30fb094
599 changed files with 65988 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
-- 将 user_temp 迁移为 usermobile 为空)与 user_auth
START TRANSACTION;
-- 1) 迁移临时用户到 usermobile 置为空)
INSERT INTO
`user` (
`delete_time`,
`del_state`,
`version`,
`mobile`,
`password`,
`nickname`,
`info`,
`inside`
)
SELECT NULL, 0, COALESCE(ut.version, 0), NULL, NULL, NULL, '', 0
FROM `user_temp` ut
WHERE
ut.del_state = 0;
-- 2) 将临时认证迁移到 user_auth按插入顺序关联最近插入的 user.id
INSERT INTO
`user_auth` (
`delete_time`,
`del_state`,
`version`,
`user_id`,
`auth_key`,
`auth_type`
)
SELECT NULL, 0, COALESCE(ut.version, 0), u.id, ut.auth_key, ut.auth_type
FROM `user_temp` ut
JOIN `user` u ON u.del_state = 0
AND u.mobile IS NULL
WHERE
ut.del_state = 0;
-- 注意以上为示意实际生产应通过显式映射如临时ID与新UserID映射表确保一一对应避免笛卡尔匹配。
COMMIT;
-- 唯一索引保障
ALTER TABLE `user_auth`
ADD UNIQUE INDEX `idx_auth_type_key` (`auth_type`, `auth_key`);