-- S3 MDP 运行监控日志
-- 记录整轮 source -> mdp_stg_* -> mdp_std_* -> dwd_* 同步转换结果。

CREATE TABLE IF NOT EXISTS mdp_transform_run_log (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    tenant_id BIGINT NOT NULL DEFAULT 0,
    job_code VARCHAR(100) NOT NULL,
    job_name VARCHAR(200) NOT NULL,
    trigger_type VARCHAR(30) NOT NULL DEFAULT 'AUTO',
    batch_id VARCHAR(100) NOT NULL,
    status VARCHAR(30) NOT NULL DEFAULT 'RUNNING',
    start_time DATETIME NOT NULL,
    end_time DATETIME NULL,
    duration_ms INT NULL,
    stage_rows INT NOT NULL DEFAULT 0,
    standard_rows INT NOT NULL DEFAULT 0,
    dwd_rows INT NOT NULL DEFAULT 0,
    error_message TEXT NULL,
    summary_json JSON NULL,
    create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY uk_batch (batch_id),
    KEY idx_job_start (job_code, start_time),
    KEY idx_status_start (status, start_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='MDP整轮同步转换运行日志';
