Files
intelligence_system/tools/SQL.sql
T
2025-10-17 17:59:28 +08:00

18 lines
1.4 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 main_task (
task_id INT AUTO_INCREMENT PRIMARY KEY COMMENT '任务唯一ID',
task_name VARCHAR(100) NOT NULL COMMENT '任务名称',
task_type VARCHAR(50) NOT NULL COMMENT '任务类型(如processor、collector等)',
module_path VARCHAR(255) NOT NULL COMMENT '任务模块路径(如processors.data_checker',
cron_expression VARCHAR(100) NOT NULL COMMENT 'Cron表达式(调度频率)',
time_zone VARCHAR(50) DEFAULT 'Asia/Shanghai' COMMENT '时区', -- 补充此字段
next_run_time DATETIME NOT NULL COMMENT '下次运行时间',
last_run_time DATETIME NULL COMMENT '上次运行时间',
last_run_status ENUM('success', 'failed', 'pending') DEFAULT 'pending' COMMENT '上次运行状态',
run_count INT DEFAULT 0 COMMENT '运行次数统计',
is_active TINYINT(1) DEFAULT 1 COMMENT '是否活跃(1=启用,0=禁用)',
is_running TINYINT(1) DEFAULT 0 COMMENT '是否正在运行(1=运行中,0=未运行)',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
INDEX idx_next_run (next_run_time) COMMENT '优化下次运行时间查询', -- 建议保留索引提升性能
INDEX idx_active (is_active) COMMENT '优化活跃任务查询' -- 建议保留索引提升性能
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='任务调度主表';