ALTER TABLE lead_contract_data
    ADD COLUMN source VARCHAR(30) NOT NULL DEFAULT 'manual' AFTER lead_id,
    ADD COLUMN source_reference VARCHAR(100) NULL AFTER source,
    ADD COLUMN snapshot_id INT UNSIGNED NULL AFTER source_reference,
    ADD COLUMN margin_total DECIMAL(13,2) NULL AFTER outstanding_balance,
    ADD COLUMN margin_available DECIMAL(13,2) NULL AFTER margin_total,
    ADD COLUMN raw_payload JSON NULL AFTER evaluation_follow_up,
    ADD CONSTRAINT fk_contract_data_rvx_snapshot FOREIGN KEY (snapshot_id) REFERENCES lead_rvx_snapshots (id) ON DELETE SET NULL,
    ADD INDEX idx_contract_data_source (source);
