-- CostusWorx © 2026 — Fund types reference table
-- Run once. fund_types replaces the hardcoded ENUM in application code.

CREATE TABLE IF NOT EXISTS fund_types (
    id         INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    code       VARCHAR(40)  NOT NULL UNIQUE,
    label      VARCHAR(80)  NOT NULL,
    sort_order TINYINT      NOT NULL DEFAULT 0,
    is_active  TINYINT(1)   NOT NULL DEFAULT 1,
    created_at TIMESTAMP    DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO fund_types (code, label, sort_order) VALUES
('unit_trust',     'Unit Trust',      1),
('etf',            'ETF',             2),
('living_annuity', 'Living Annuity',  3),
('money_market',   'Money Market',    4),
('other',          'Other',           9);
