© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
10 replies
jamielarkspur1995

Create user trigger 500

I have this trigger:

create or replace function public.handle_new_user()
returns trigger as
$$
  begin
    insert into public."User" (id, email, userType)
    values (new.id, new.email, new.raw_user_meta_data->>'user_type');
    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."User" (id, email, userType)
    values (new.id, new.email, new.raw_user_meta_data->>'user_type');
    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();


But I get a 500 on user signup. I can see the user_type field in the auth panel.

My only guess is that
userType
userType
in the
User
User
table is an enum, but I don't know how to cast it properly
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

error 500 trying to create a user
SupabaseSSupabase / help-and-questions
5mo ago
Which case shows error 500 when create existing user
SupabaseSSupabase / help-and-questions
3y ago
Create trigger that adds a role when a user create an account.
SupabaseSSupabase / help-and-questions
3y ago
Error 500 - user management
SupabaseSSupabase / help-and-questions
5mo ago