-- Add ingestion tracking and review workflow columns to ap_invoices.
-- source:          'manual' = created in UI; 'email_ingest' = created by ingest bot
-- review_status:   set to 'pending_review' by ingest bot; NULL for manually-created invoices
-- po_match_status: result of PO lookup during ingest
-- confidence_score: Claude extraction confidence (0.000–1.000)

ALTER TABLE ap_invoices
  ADD COLUMN source           ENUM('manual','email_ingest') NOT NULL DEFAULT 'manual'          AFTER invoice_type,
  ADD COLUMN review_status    ENUM('pending_review','accepted','rejected') NULL DEFAULT NULL    AFTER source,
  ADD COLUMN po_match_status  ENUM('matched_approved','matched_pending','no_match','n/a') NULL DEFAULT NULL  AFTER review_status,
  ADD COLUMN confidence_score DECIMAL(4,3) NULL DEFAULT NULL                                   AFTER po_match_status,
  ADD KEY    idx_review_status (review_status);
