fix(db): migrations failing on a fresh supabase instance (#645)

* fix(db): add extension function wrappers (avoid shadowing gen_random_uuid)

Signed-off-by: filip <filip.harald@gmail.com>

* test: added test for extension function wrappers (uuid_generate_v4 and gen_random_bytes) in public schema, covering existence, delegation, correctness, properties, and idempotency.

Signed-off-by: filip <filip.harald@gmail.com>

---------

Signed-off-by: filip <filip.harald@gmail.com>
This commit is contained in:
Filip
2026-06-08 09:41:36 +02:00
committed by GitHub
parent 23863371dd
commit 3d3f242d11
2 changed files with 220 additions and 0 deletions
@@ -0,0 +1,26 @@
CREATE SCHEMA IF NOT EXISTS extensions;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA extensions;
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA extensions;
CREATE OR REPLACE FUNCTION public.uuid_generate_v4()
RETURNS uuid
LANGUAGE sql
VOLATILE
PARALLEL SAFE
SET search_path = ''
AS $$
SELECT extensions.uuid_generate_v4();
$$;
CREATE OR REPLACE FUNCTION public.gen_random_bytes(size integer)
RETURNS bytea
LANGUAGE sql
VOLATILE
PARALLEL SAFE
SET search_path = ''
AS $$
SELECT extensions.gen_random_bytes(size);
$$;
NOTIFY pgrst, 'reload schema';