news-classifier/crawler-module/migrations/002_create_schedules_table.sql

18 lines
956 B
SQL
Raw Permalink 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 schedules (
id INT AUTO_INCREMENT PRIMARY KEY COMMENT '定时任务ID',
name VARCHAR(100) UNIQUE NOT NULL COMMENT '定时任务名称',
crawlers JSON NOT NULL COMMENT '爬虫列表,如["netease:tech", "kr36:ai"]',
cron_expr VARCHAR(100) NOT NULL COMMENT 'Cron表达式如"0 2 * * *"',
max_articles INT NULL COMMENT '最大文章数限制',
is_enabled BOOLEAN DEFAULT TRUE COMMENT '是否启用',
last_run_at TIMESTAMP NULL COMMENT '上次运行时间',
next_run_at TIMESTAMP NULL COMMENT '下次运行时间',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX idx_enabled (is_enabled) COMMENT '启用状态索引',
INDEX idx_next_run (next_run_at) COMMENT '下次运行时间索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='定时任务表';