USE db_abos_v0.1;

CREATE TABLE IF NOT EXISTS fact_campaigns (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    tenant_id INT NOT NULL,
    business_id INT NULL,
    name VARCHAR(255) NOT NULL,
    type VARCHAR(100) NOT NULL,
    status VARCHAR(50) NOT NULL DEFAULT 'Draft',
    start_date DATE NULL,
    end_date DATE NULL,
    budget DECIMAL(15,2) NULL,
    actual_spend DECIMAL(15,2) NULL DEFAULT 0.00,
    target_audience VARCHAR(255) NULL,
    owner_id INT NULL,
    notes TEXT NULL,
    created_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6),
    created_by INT NULL,
    updated_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    updated_by INT NULL,
    is_deleted TINYINT NOT NULL DEFAULT 0,
    INDEX idx_fact_campaigns_tenant (tenant_id),
    INDEX idx_fact_campaigns_status (tenant_id, status),
    INDEX idx_fact_campaigns_owner (owner_id)
);
