fix(aihr): bind SOP reviews to pilot identity

This commit is contained in:
2026-07-14 15:43:23 +08:00
parent 64f369eff0
commit 14d91f86a9
7 changed files with 113 additions and 27 deletions
@@ -237,6 +237,7 @@ CREATE TABLE IF NOT EXISTS `aihr_sop_answer_review` (
`reference_text` varchar(1000) DEFAULT NULL COMMENT '引用',
`snippet_count` int DEFAULT 0 COMMENT '命中片段数',
`source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源',
`requester_ext_party_id` varchar(100) DEFAULT NULL COMMENT '提问员工外部主体ID',
`prompt_version` varchar(80) DEFAULT NULL COMMENT '答案生成提示词版本',
`usable` tinyint DEFAULT NULL COMMENT '人工评审是否可用',
`reviewer` varchar(100) DEFAULT NULL COMMENT '评审人',
@@ -0,0 +1,24 @@
-- AIHR SOP 问答提问员工主体迁移(MySQL 8.x)
-- 仅补齐结构,不写入业务数据;可重复执行。
SET @aihr_sop_review_table_exists := (
SELECT COUNT(*)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'aihr_sop_answer_review'
);
SET @aihr_sop_requester_exists := (
SELECT COUNT(*)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'aihr_sop_answer_review'
AND COLUMN_NAME = 'requester_ext_party_id'
);
SET @aihr_sop_requester_ddl := IF(
@aihr_sop_review_table_exists = 1 AND @aihr_sop_requester_exists = 0,
'ALTER TABLE aihr_sop_answer_review ADD COLUMN `requester_ext_party_id` varchar(100) DEFAULT NULL COMMENT ''提问员工外部主体ID'' AFTER `source`',
'SELECT 1'
);
PREPARE aihr_sop_requester_stmt FROM @aihr_sop_requester_ddl;
EXECUTE aihr_sop_requester_stmt;
DEALLOCATE PREPARE aihr_sop_requester_stmt;