hyapp-server/server/admin/migrations/100_external_admin_global_username.sql

14 lines
911 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.

SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
-- 外管登录不再接受客户端选择 App因此 username 必须在整张账号表中唯一,
-- 服务端才能仅凭账号确定唯一租户。该 DDL 不改写任何账号,也不会自动重命名冲突凭据:
-- 若历史数据存在同名账号,唯一索引构建会失败并保留原复合索引,要求人工确认归属后再重跑。
-- external_admin_accounts 是小型凭据表INPLACE + LOCK=NONE 只扫描该表建立二级索引,
-- 不扫描 users、房间、钱包等业务表并允许迁移期间继续读写。并发写入若制造同名账号
-- MySQL 会让索引构建失败而不是提交不唯一结构,保持 fail-closed。
ALTER TABLE external_admin_accounts
ADD UNIQUE KEY uk_external_admin_accounts_username (username),
DROP INDEX uk_external_admin_accounts_app_username,
ALGORITHM=INPLACE,
LOCK=NONE;