-- 创建执行日志表
CREATE TABLE IF NOT EXISTS execution_logs (
    id CHAR(36) PRIMARY KEY COMMENT '日志ID',
    execution_id CHAR(36) NOT NULL COMMENT '执行ID',
    node_id VARCHAR(100) COMMENT '节点ID',
    node_type VARCHAR(50) COMMENT '节点类型',
    level VARCHAR(20) NOT NULL COMMENT '日志级别: INFO/WARN/ERROR/DEBUG',
    message TEXT NOT NULL COMMENT '日志消息',
    data JSON COMMENT '附加数据',
    timestamp DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '时间戳',
    duration INT COMMENT '执行耗时(ms)',
    FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE CASCADE,
    INDEX idx_execution_id (execution_id),
    INDEX idx_node_id (node_id),
    INDEX idx_level (level),
    INDEX idx_timestamp (timestamp)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='执行日志表';
