From 1e34707258f86105a827e79b533d1693e05f16fc Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 31 May 2026 00:50:32 -0500 Subject: [PATCH] migration 082: widen tickets.category CHECK for lead-capture categories Co-Authored-By: Claude Opus 4.8 (1M context) --- .../082_tickets_lead_categories.sql | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 api/migrations/082_tickets_lead_categories.sql diff --git a/api/migrations/082_tickets_lead_categories.sql b/api/migrations/082_tickets_lead_categories.sql new file mode 100644 index 0000000..d5b2c97 --- /dev/null +++ b/api/migrations/082_tickets_lead_categories.sql @@ -0,0 +1,20 @@ +-- Widen tickets.category to allow lead-capture categories posted by the DOT +-- compliance checker (insurance, business close-out, truck-sale routing). +-- The CHECK constraint previously only allowed the support-widget categories, +-- so these INSERTs failed with a 500. + +ALTER TABLE tickets DROP CONSTRAINT IF EXISTS tickets_category_check; + +ALTER TABLE tickets ADD CONSTRAINT tickets_category_check CHECK ( + category = ANY (ARRAY[ + 'question', + 'support', + 'issue', + 'service_request', + 'quote', + 'insurance_lead', + 'business_closeout', + 'truck_sale_quickcash', + 'truck_sale_marketplace' + ]::text[]) +);