-- “我的 - MCP Key”独立表。 -- 刻意不碰框架自带的 sys_bot_credential:管理端现有 Bot 凭证继续按原逻辑使用, -- 本表只承载业务端用户自助创建的多把 MCP key。 create table if not exists crm_user_mcp_key ( id bigint generated by default as identity primary key, key_id varchar(64) not null, secret_hash varchar(255) not null, user_id bigint not null, name varchar(64) not null default '', status varchar(16) not null default '0', expire_time timestamp, last_access_time timestamp, last_access_ip varchar(128), created_at timestamp not null default now(), updated_at timestamp not null default now(), constraint uk_crm_user_mcp_key_id unique (key_id) ); create index if not exists idx_crm_user_mcp_key_user on crm_user_mcp_key (user_id, created_at desc); -- secret_plain:Key 明文,给「我的 - MCP Key 管理」重复查看用。 -- 认证仍然只比对 secret_hash(BCrypt),明文只是展示副本,不参与校验; -- 没有这一列时用户只能看一次,而 MCP 客户端经常要回头取 Key。 alter table if exists crm_user_mcp_key add column if not exists secret_plain varchar(128); -- 回滚: -- drop index if exists idx_crm_user_mcp_key_user; -- drop table if exists crm_user_mcp_key;