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' + ));