© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
15 replies
Zeph

Trigger Function

I currently have this trigger and function to add a new row to my public users table whenever a new user signs up.
How do I also trigger a function that adds a row in the
folder
folder
table with the name set to 'default' and the userId set to the new user that was just created?
My
folder
folder
table has the following columns: id, name, userId

Thank you!

create or replace function public.handle_new_user() 
returns trigger as $$
begin
  insert into public.users (id, email)
  values (new.id, new.email);
  return new;
end;
$$ language plpgsql security definer;

drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user()
create or replace function public.handle_new_user() 
returns trigger as $$
begin
  insert into public.users (id, email)
  values (new.id, new.email);
  return new;
end;
$$ language plpgsql security definer;

drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user()
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Edge function <> Trigger
SupabaseSSupabase / help-and-questions
13mo ago
Trigger function help
SupabaseSSupabase / help-and-questions
3y ago
Error in trigger function
SupabaseSSupabase / help-and-questions
4y ago
Help with a trigger + function
SupabaseSSupabase / help-and-questions
4y ago