© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
2 replies
phil

Trigger on auth.users causes permission denied for schema public

When a user signs up, i have a trigger that runs to create an entry in another table called public.profiles.
it runs this function:

begin
  insert into public.profiles (id, email, first_name, last_name)
  values (new.id, COALESCE(new.raw_user_meta_data->>'email', new.email), split_part(new.raw_user_meta_data ->>'full_name', ' ', 1), substring(new.raw_user_meta_data ->>'full_name', (length(split_part(new.raw_user_meta_data ->>'full_name', ' ', 1)))+2,(length(new.raw_user_meta_data ->>'full_name')) - (length(split_part(new.raw_user_meta_data ->>'full_name', ' ', 1)))+1));

  insert into public.settings (id)
  values (new.id);
  
  return new;
end;
begin
  insert into public.profiles (id, email, first_name, last_name)
  values (new.id, COALESCE(new.raw_user_meta_data->>'email', new.email), split_part(new.raw_user_meta_data ->>'full_name', ' ', 1), substring(new.raw_user_meta_data ->>'full_name', (length(split_part(new.raw_user_meta_data ->>'full_name', ' ', 1)))+2,(length(new.raw_user_meta_data ->>'full_name')) - (length(split_part(new.raw_user_meta_data ->>'full_name', ' ', 1)))+1));

  insert into public.settings (id)
  values (new.id);
  
  return new;
end;


Now when I test this, i get the following error in the logs:
"component":"api","error":"failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: permission denied for schema public (SQLSTATE 42501)","level":"error","method":"POST","msg":"500: Database error creating new 
"component":"api","error":"failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: permission denied for schema public (SQLSTATE 42501)","level":"error","method":"POST","msg":"500: Database error creating new 


When I remove the trigger then the auth.user is created but of course the public.profiles/settings is not.

Anyone see anything wrong here?
image.png
image.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

ERROR: permission denied for schema public (SQLSTATE 42501)
SupabaseSSupabase / help-and-questions
5mo ago
Help with Supabase Trigger: Permission Denied for Anon Role on auth.users Table
SupabaseSSupabase / help-and-questions
13mo ago
permission denied for table users
SupabaseSSupabase / help-and-questions
3mo ago
Permission denied to schema public (403 error)
SupabaseSSupabase / help-and-questions
4mo ago