-- quotations/invoices money columns were DECIMAL(10,2) (max 99,999,999.99).
-- Real quotations already reach ~18.6M/~12.3M, so large orders overflow the
-- column and MySQL throws a raw PDOException during createQuotation/createInvoice.
-- Widen to DECIMAL(15,2) (max ~9.99 trillion) to accommodate large quantity x price totals.
ALTER TABLE quotations
    MODIFY subtotal DECIMAL(15,2) NOT NULL,
    MODIFY surtax DECIMAL(15,2) NOT NULL,
    MODIFY total_amount DECIMAL(15,2) NOT NULL;
ALTER TABLE quotation_items MODIFY unit_price DECIMAL(15,2) NOT NULL;

ALTER TABLE invoices
    MODIFY subtotal DECIMAL(15,2) NOT NULL,
    MODIFY surtax DECIMAL(15,2) NOT NULL,
    MODIFY total_amount DECIMAL(15,2) NOT NULL;
ALTER TABLE invoice_items MODIFY unit_price DECIMAL(15,2) NOT NULL;

-- 'draft' status lets a quotation/invoice that failed validation or hit a DB
-- error during creation be persisted instead of losing the user's input, so
-- it can be reopened and completed via edit_quotation.php / edit_invoice.php.
ALTER TABLE quotations
    MODIFY status ENUM('draft','pending','converted','approved','rejected','expired') DEFAULT 'pending';
ALTER TABLE invoices
    MODIFY status ENUM('draft','pending','converted','approved','expired') DEFAULT 'pending';
