-- 创建告警表
CREATE TABLE IF NOT EXISTS cf_alert (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    tenant_id VARCHAR(255) NOT NULL,
    alert_type VARCHAR(50),
    severity VARCHAR(50),
    message TEXT,
    status VARCHAR(50),
    source VARCHAR(255),
    threshold VARCHAR(255),
    actual_value VARCHAR(255),
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    resolved_at DATETIME
);

-- 为告警表添加索引
CREATE INDEX IF NOT EXISTS idx_alert_tenant_id ON cf_alert(tenant_id);
CREATE INDEX IF NOT EXISTS idx_alert_status ON cf_alert(status);
CREATE INDEX IF NOT EXISTS idx_alert_severity ON cf_alert(severity);
CREATE INDEX IF NOT EXISTS idx_alert_alert_type ON cf_alert(alert_type);
CREATE INDEX IF NOT EXISTS idx_alert_created_at ON cf_alert(created_at);
