migration 098: allow compliance order types in order_audit_log

The admin compliance-orders approve/re-arm actions write order_audit_log rows
with order_type='compliance', but the CHECK constraint (from migration 004)
only allowed formation/service/quote -- so every approve failed with a 500
('Approve failed.'). Expand the constraint to include compliance + compliance_batch.
This commit is contained in:
justin 2026-06-16 02:49:46 -05:00
parent 3df3a08221
commit 73c27c75b1

View file

@ -0,0 +1,17 @@
-- 098: Allow compliance order types in order_audit_log.
--
-- order_audit_log was created (migration 004) for formation orders only, with a
-- CHECK constraint limiting order_type to ('formation','service','quote'). The
-- admin compliance-orders dashboard writes audit entries for compliance orders
-- (approve-for-submission, intake re-arm), which were rejected by that check and
-- surfaced as "Approve failed" 500s. Add the compliance order types.
--
-- Idempotent: drops and recreates the constraint with the expanded value set.
ALTER TABLE order_audit_log DROP CONSTRAINT IF EXISTS order_audit_log_order_type_check;
ALTER TABLE order_audit_log
ADD CONSTRAINT order_audit_log_order_type_check
CHECK (order_type IN (
'formation', 'service', 'quote', 'compliance', 'compliance_batch'
));