-- 脚本操作记录表
CREATE TABLE script_operation_log (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    operation_type VARCHAR(50) NOT NULL COMMENT '操作类型: SELECT_REGION, REFRESH, SAVE_TOTAL_TIMES, REFUND_ORDER',
    machine_id VARCHAR(50) NOT NULL COMMENT '设备/机器ID',
    request_url TEXT NOT NULL COMMENT '请求URL',
    request_params JSON COMMENT '请求参数(JSON格式)',
    response_result TEXT COMMENT '响应结果',
    success BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否成功',
    error_message TEXT COMMENT '错误信息',
    duration_ms INT COMMENT '请求耗时(毫秒)',
    request_time DATETIME NOT NULL COMMENT '请求发送时间',
    response_time DATETIME COMMENT '响应接收时间',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    
    INDEX idx_operation_type (operation_type),
    INDEX idx_machine_id (machine_id),
    INDEX idx_request_time (request_time),
    INDEX idx_success (success)
) COMMENT '脚本操作记录表';
