-- 问师傅短期多轮会话。只保存最近六轮的脱敏截断 JSON,30 分钟不活跃过期。 CREATE TABLE IF NOT EXISTS `aihr_knowledge_conversation` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', `tenant_id` varchar(20) NOT NULL COMMENT '租户编号', `app_id` bigint NOT NULL COMMENT '内部调用应用ID', `user_id` bigint NOT NULL COMMENT '内部用户ID', `conversation_id` varchar(64) NOT NULL COMMENT '客户端随机会话ID', `project_code` varchar(100) DEFAULT NULL COMMENT '当前项目编码;多项目会话严格隔离', `version` bigint NOT NULL DEFAULT 0 COMMENT '乐观并发版本', `context_json` json DEFAULT NULL COMMENT '最近六轮脱敏短期上下文', `expires_time` datetime NOT NULL COMMENT '不活跃过期时间', `create_time` datetime NOT NULL COMMENT '创建时间', `update_time` datetime NOT NULL COMMENT '更新时间', PRIMARY KEY (`id`), UNIQUE KEY `uk_aihr_knowledge_conversation` (`tenant_id`, `app_id`, `user_id`, `conversation_id`), KEY `idx_aihr_knowledge_conversation_expire` (`tenant_id`, `expires_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='知识问答短期会话';