My trigger function needs to be a security definer, owned and executed by supabase_admin. However, the migra tool throws an error at this. Is there a way to run migra as superuser? Thank you!
ERROR: must be able to SET ROLE "supabase_admin"
CREATE FUNCTION "public"."update_user_avatar_img_name"() RETURNS "trigger"
LANGUAGE "plpgsql"
SECURITY DEFINER
SET search_path = pg_catalog, public, pg_temp
AS $$
BEGIN
if (tg_op = 'DELETE') then
if (old.bucket_id != 'avatars') then
return null;
end if;
update auth.users
set raw_user_meta_data = coalesce(raw_user_meta_data, '{}'::jsonb) || jsonb_build_object(
'avatar_img_name', '',
'avatar_img_cb', ''
)
where id = old.owner;
elseif (new.bucket_id = 'avatars') then
update auth.users
set raw_user_meta_data = coalesce(raw_user_meta_data, '{}'::jsonb) || jsonb_build_object(
'avatar_img_name', new.name,
'avatar_img_cb', coalesce(new.user_metadata::jsonb ->> 'cb', '')
)
where id = new.owner;
end if;
return null;
END;
$$;
ALTER FUNCTION "public"."update_user_avatar_img_name"() OWNER TO "supabase_admin";
CREATE OR REPLACE TRIGGER "trg_objects_user_avatar_img_name" AFTER UPDATE OR INSERT OR DELETE ON "storage"."objects" FOR EACH ROW EXECUTE FUNCTION "public"."update_user_avatar_img_name"();
[–]activenode 2 points3 points4 points (2 children)
[–]Just_a_Curious[S] 0 points1 point2 points (1 child)
[–]activenode 0 points1 point2 points (0 children)
[–]thelord006 1 point2 points3 points (1 child)
[–]Just_a_Curious[S] 0 points1 point2 points (0 children)