CREATE TABLE IF NOT EXISTS monthly_report_subdivision (
    id INT AUTO_INCREMENT PRIMARY KEY,
    subdivision_id INT NOT NULL,
    bulan TINYINT NOT NULL,
    tahun SMALLINT NOT NULL,

    pendahuluan TEXT NULL,
    analisis TEXT NULL,
    simpulan TEXT NULL,
    catatan TEXT NULL,

    status ENUM('draft','submitted','approved_kadiv') NOT NULL DEFAULT 'draft',

    created_by INT NULL,
    updated_by INT NULL,
    submitted_at DATETIME NULL,
    approved_kadiv_at DATETIME NULL,

    created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

    UNIQUE KEY uniq_subdivision_period (subdivision_id, bulan, tahun)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS monthly_report_division (
    id INT AUTO_INCREMENT PRIMARY KEY,
    division_id INT NOT NULL,
    bulan TINYINT NOT NULL,
    tahun SMALLINT NOT NULL,

    pendahuluan TEXT NULL,
    analisis TEXT NULL,
    simpulan TEXT NULL,
    catatan TEXT NULL,

    status ENUM('draft','submitted') NOT NULL DEFAULT 'draft',

    created_by INT NULL,
    updated_by INT NULL,
    submitted_at DATETIME NULL,

    created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

    UNIQUE KEY uniq_division_period (division_id, bulan, tahun)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;