fix(aihr): recover stalled media processing

This commit is contained in:
key
2026-07-29 15:09:01 +08:00
parent f17b904b5c
commit 652e48884b
18 changed files with 838 additions and 76 deletions
@@ -0,0 +1,36 @@
-- 资料处理媒体重试:记录从既有知识附件重新解析的来源,支持直接从 OSS 原件重新入队。
-- 可重复执行;依赖 aihr_knowledge_upload_item。
SET @has_source_attach_id := (
SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'aihr_knowledge_upload_item'
AND column_name = 'source_attach_id'
);
SET @media_reprocess_ddl := IF(
@has_source_attach_id = 0,
'ALTER TABLE aihr_knowledge_upload_item ADD COLUMN source_attach_id bigint DEFAULT NULL COMMENT ''从既有附件重新解析时的附件ID'' AFTER staging_path',
'SELECT 1'
);
PREPARE media_reprocess_stmt FROM @media_reprocess_ddl;
EXECUTE media_reprocess_stmt;
DEALLOCATE PREPARE media_reprocess_stmt;
SET @has_media_source_index := (
SELECT COUNT(*) FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'aihr_knowledge_upload_item'
AND index_name = 'idx_aihr_upload_item_source'
);
SET @media_reprocess_ddl := IF(
@has_media_source_index = 0,
'ALTER TABLE aihr_knowledge_upload_item ADD KEY idx_aihr_upload_item_source (tenant_id, source_attach_id, id)',
'SELECT 1'
);
PREPARE media_reprocess_stmt FROM @media_reprocess_ddl;
EXECUTE media_reprocess_stmt;
DEALLOCATE PREPARE media_reprocess_stmt;
SET @has_source_attach_id := NULL;
SET @has_media_source_index := NULL;
SET @media_reprocess_ddl := NULL;