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: reference function from function

Brad Barbineace447eeaba
diff --git a/packages/database/supabase/migrations/20250923030431_uuid-shim.sql b/packages/database/supabase/migrations/20250923030431_uuid-shim.sql
new file mode 100644
index 0000000000..c63acc5bc0
--- /dev/null
+++ b/packages/database/supabase/migrations/20250923030431_uuid-shim.sql
@@ -0,0 +1,23 @@
+CREATE EXTENSION IF NOT EXISTS pgcrypto;
+
+CREATE OR REPLACE FUNCTION id(_prefix TEXT DEFAULT NULL)
+RETURNS TEXT
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ _uuid TEXT;
+BEGIN
+ _uuid := REPLACE(uuid_to_base58(extensions.gen_random_uuid()), '-', '');
+ IF _prefix IS NOT NULL THEN
+ RETURN _prefix || '_' || _uuid;
+ ELSE
+ RETURN _uuid;
+ END IF;
+END;
+$$;
+
+CREATE OR REPLACE FUNCTION public.uuid_generate_v4()
+RETURNS uuid
+LANGUAGE sql
+STABLE
+AS $$ SELECT extensions.uuid_generate_v4() $$;
\ No newline at end of file