news-classifier/crawler-module/migrations/001_create_tasks_table.sql

21 lines
1.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 创建任务历史表
-- 用于存储爬虫任务的执行历史和统计信息
CREATE TABLE IF NOT EXISTS crawler_tasks (
id VARCHAR(36) PRIMARY KEY COMMENT '任务IDUUID',
status ENUM('pending', 'running', 'completed', 'failed', 'cancelled') NOT NULL DEFAULT 'pending' COMMENT '任务状态',
crawlers JSON NOT NULL COMMENT '爬虫列表,如["netease:tech", "kr36:ai"]',
max_articles INT NULL COMMENT '最大文章数限制',
crawled_count INT DEFAULT 0 COMMENT '爬取的文章总数',
inserted_count INT DEFAULT 0 COMMENT '成功插入的文章数',
duplicate_count INT DEFAULT 0 COMMENT '重复的文章数',
error_message TEXT NULL COMMENT '错误信息',
started_at TIMESTAMP NULL COMMENT '开始时间',
completed_at TIMESTAMP NULL COMMENT '完成时间',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX idx_status (status) COMMENT '状态索引',
INDEX idx_created_at (created_at) COMMENT '创建时间索引',
INDEX idx_completed_at (completed_at) COMMENT '完成时间索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='爬虫任务历史表';