feat(broadcast): add multi-role insight contract
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
-- 公司消息 R4:同一公司文件的多岗位 AI 解读。
|
||||
-- 可重复执行,需在 aihr_20260724_broadcast_attachment_mysql8.sql 之后执行。
|
||||
|
||||
SET @has_broadcast_insight_status := (
|
||||
SELECT COUNT(*) FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 'aihr_broadcast_attachment'
|
||||
AND column_name = 'insight_status'
|
||||
);
|
||||
SET @broadcast_insight_ddl := IF(
|
||||
@has_broadcast_insight_status = 0,
|
||||
'ALTER TABLE aihr_broadcast_attachment ADD COLUMN insight_status varchar(20) NOT NULL DEFAULT ''NOT_PROCESSED'' COMMENT ''NOT_PROCESSED/PENDING/PROCESSING/READY/PARTIAL/FAILED'' AFTER summary',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE broadcast_insight_stmt FROM @broadcast_insight_ddl; EXECUTE broadcast_insight_stmt; DEALLOCATE PREPARE broadcast_insight_stmt;
|
||||
|
||||
SET @has_broadcast_insights_json := (
|
||||
SELECT COUNT(*) FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 'aihr_broadcast_attachment'
|
||||
AND column_name = 'insights_json'
|
||||
);
|
||||
SET @broadcast_insight_ddl := IF(
|
||||
@has_broadcast_insights_json = 0,
|
||||
'ALTER TABLE aihr_broadcast_attachment ADD COLUMN insights_json longtext DEFAULT NULL COMMENT ''经原文引用校验的多岗位解读 JSON'' AFTER insight_status',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE broadcast_insight_stmt FROM @broadcast_insight_ddl; EXECUTE broadcast_insight_stmt; DEALLOCATE PREPARE broadcast_insight_stmt;
|
||||
|
||||
SET @has_broadcast_insight_version := (
|
||||
SELECT COUNT(*) FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 'aihr_broadcast_attachment'
|
||||
AND column_name = 'insight_version'
|
||||
);
|
||||
SET @broadcast_insight_ddl := IF(
|
||||
@has_broadcast_insight_version = 0,
|
||||
'ALTER TABLE aihr_broadcast_attachment ADD COLUMN insight_version varchar(30) DEFAULT NULL COMMENT ''解读规则版本'' AFTER insights_json',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE broadcast_insight_stmt FROM @broadcast_insight_ddl; EXECUTE broadcast_insight_stmt; DEALLOCATE PREPARE broadcast_insight_stmt;
|
||||
|
||||
SET @has_broadcast_insight_queue_index := (
|
||||
SELECT COUNT(*) FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'aihr_broadcast_attachment'
|
||||
AND index_name = 'idx_aihr_broadcast_attachment_insight_queue'
|
||||
);
|
||||
SET @broadcast_insight_ddl := IF(
|
||||
@has_broadcast_insight_queue_index = 0,
|
||||
'ALTER TABLE aihr_broadcast_attachment ADD KEY idx_aihr_broadcast_attachment_insight_queue (insight_status, status, update_time)',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE broadcast_insight_stmt FROM @broadcast_insight_ddl; EXECUTE broadcast_insight_stmt; DEALLOCATE PREPARE broadcast_insight_stmt;
|
||||
|
||||
SET @has_broadcast_insight_status := NULL;
|
||||
SET @has_broadcast_insights_json := NULL;
|
||||
SET @has_broadcast_insight_version := NULL;
|
||||
SET @has_broadcast_insight_queue_index := NULL;
|
||||
SET @broadcast_insight_ddl := NULL;
|
||||
Reference in New Issue
Block a user