Files
accounted/supabase/migrations/20260813213000_invoice_inbox_processing_status.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

26 lines
1.2 KiB
SQL

-- Re-admit 'processing' to the invoice_inbox_items.status CHECK.
--
-- Staged upload needs an in-flight state: the web upload route now inserts
-- the inbox row BEFORE AI extraction runs (status 'processing',
-- extracted_data NULL), answers the request immediately, and a deferred
-- worker flips the row to 'received' once extraction lands (or the sweep
-- cron does, after a crashed worker).
--
-- Supersedes the 20260504180000 tightening that removed 'processing': that
-- removal assumed extraction always completes synchronously before the row
-- exists, which stops being true with the staged upload. Email and WhatsApp
-- ingestion keep the synchronous path and never write 'processing'.
ALTER TABLE public.invoice_inbox_items
DROP CONSTRAINT IF EXISTS invoice_inbox_items_status_check;
ALTER TABLE public.invoice_inbox_items
ADD CONSTRAINT invoice_inbox_items_status_check
CHECK (status IN ('received', 'processing', 'error'));
-- Unchanged, restated so the default survives the constraint swap verbatim:
-- rows still land as 'received' unless the writer says otherwise.
ALTER TABLE public.invoice_inbox_items
ALTER COLUMN status SET DEFAULT 'received';
NOTIFY pgrst, 'reload schema';