I第一次提交
This commit is contained in:
30
sql/migration_add_catalog_extraction_status.sql
Normal file
30
sql/migration_add_catalog_extraction_status.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- 添加目录摘取状态相关字段到 t_file 表
|
||||
-- 执行时间: 2025-12-02
|
||||
|
||||
-- 添加目录摘取状态字段
|
||||
ALTER TABLE t_file ADD COLUMN IF NOT EXISTS catalog_extraction_status VARCHAR(32) DEFAULT 'not_started';
|
||||
|
||||
-- 添加目录摘取重试次数字段
|
||||
ALTER TABLE t_file ADD COLUMN IF NOT EXISTS catalog_extraction_retry_count INT DEFAULT 0 NOT NULL;
|
||||
|
||||
-- 添加目录摘取完成时间字段
|
||||
ALTER TABLE t_file ADD COLUMN IF NOT EXISTS catalog_extraction_time TIMESTAMP;
|
||||
|
||||
-- 添加字段注释
|
||||
COMMENT ON COLUMN t_file.catalog_extraction_status IS '目录摘取状态:not_started-未开始, processing-处理中, completed-已完成';
|
||||
COMMENT ON COLUMN t_file.catalog_extraction_retry_count IS '目录摘取重试次数(最多重试3次)';
|
||||
COMMENT ON COLUMN t_file.catalog_extraction_time IS '目录摘取完成时间';
|
||||
|
||||
-- 为已有数据设置初始状态
|
||||
-- 如果已经有目录记录,设置为 completed
|
||||
UPDATE t_file f
|
||||
SET catalog_extraction_status = 'completed',
|
||||
catalog_extraction_time = f.update_time
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM t_file_directory fd
|
||||
WHERE fd.file_id = f.file_id
|
||||
)
|
||||
AND (catalog_extraction_status IS NULL OR catalog_extraction_status = 'not_started');
|
||||
|
||||
-- 创建索引以提高查询性能
|
||||
CREATE INDEX IF NOT EXISTS idx_file_catalog_status ON t_file(catalog_extraction_status);
|
||||
Reference in New Issue
Block a user