From 73c27c75b17fca2d2730876f575094c75fa8e3f3 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 16 Jun 2026 02:49:46 -0500 Subject: [PATCH] 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. --- .../098_audit_log_compliance_type.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 api/migrations/098_audit_log_compliance_type.sql diff --git a/api/migrations/098_audit_log_compliance_type.sql b/api/migrations/098_audit_log_compliance_type.sql new file mode 100644 index 0000000..a4725ce --- /dev/null +++ b/api/migrations/098_audit_log_compliance_type.sql @@ -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' + ));