Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: add extensions prefix to json_matches_schema function

Brad Barbin9ff74ac14fbc
diff --git a/packages/database/supabase/migrations/20250925123226_integration-verification-fix.sql b/packages/database/supabase/migrations/20250925123226_integration-verification-fix.sql
new file mode 100644
index 0000000000..5551a78d10
--- /dev/null
+++ b/packages/database/supabase/migrations/20250925123226_integration-verification-fix.sql
@@ -0,0 +1,11 @@
+-- add the extensions schema to the function
+CREATE OR REPLACE FUNCTION verify_integration() RETURNS trigger AS $verify_integration$
+ DECLARE integration_schema JSON;
+ BEGIN
+ SELECT jsonschema INTO integration_schema FROM public.integration WHERE id = NEW.id;
+ IF NEW.active = TRUE AND NOT extensions.json_matches_schema(integration_schema, NEW.metadata) THEN
+ RAISE EXCEPTION 'metadata does not match jsonschema';
+ END IF;
+ RETURN NEW;
+ END;
+$verify_integration$ LANGUAGE plpgsql SECURITY DEFINER;
\ No newline at end of file