Supabase - store UUID of sponsor during Signup
I create an affiliate system . Backend is Supabase . First I get a UUID from auth .users .id I want to store this as a sponsor _id into a public table called "affilaite _tree " I used the user management tutorial to setup the trigger and function . When I just insert the new .id into affiliate _tree everything works as expected . When I want to store the sponsor _id in the function as well , I get an error stating that the sponsor _id is type text and not type uuid . How can I solve this error to store the sponsor _id as UUID ? In the pictures you see how the payload object is structured . The sponsor _id is currently type "string " . I also added a screenshot of the error message . ✅1I was able to fix it by casting the variable from text to UUID inside my Supabase function : Previous Function Code : Here , the sponsor _id was of type text insert into public.affiliate_tree (id, sponsor_id)
values (new.id, new.raw_user_meta_data->>'sponsor_id');
return new;
end;Working Function Code : Here , the sponsor _id is now casted to type UUID insert into public.affiliate_tree (id, sponsor_id)
values (new.id, (new.raw_user_meta_data->>'sponsor_id')::UUID);
return new;
end;



.jpeg/public)