-- 005_output.sql — tabel hasil kalkulasi & laporan (WP-0B)

CREATE TABLE calc_result (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    version_id INT UNSIGNED NOT NULL,
    measure_code VARCHAR(40) NOT NULL,
    ref VARCHAR(40) NULL,
    month TINYINT NULL,
    value DECIMAL(18,4) NOT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY uq_calc_result (version_id, measure_code, ref, month)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE statement_line (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    report_code VARCHAR(20) NOT NULL,
    line_no INT NOT NULL,
    label VARCHAR(120) NOT NULL,
    expr VARCHAR(255) NULL,
    indent TINYINT NOT NULL DEFAULT 0,
    PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
