-- =============================================================================
-- Add ra_bill_number to payment_requests
-- Serial number unique per (project_id, vendor_id); assigned on first submit only.
-- =============================================================================

ALTER TABLE payment_requests
  ADD COLUMN ra_bill_number INT UNSIGNED NULL AFTER invoice_amount,
  ADD UNIQUE KEY uq_payment_requests_project_vendor_ra (project_id, vendor_id, ra_bill_number),
  ADD INDEX idx_payment_requests_ra_bill (project_id, vendor_id, ra_bill_number);
