Failed to create database function: failed to create pg.functions: syntax error at or near "create"

Hey devs, am getting this error when trying to make a function that stores new users from the auth.user table to public.user table.
--Insert a row into public.user
create function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
  insert into public.user (id, name, email)
  values (new.id, new.name, new.email);
  return new;
end;
$$;

-- trigger the function every time a user is created
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();
Screenshot_2023-12-15_135541.png
Was this page helpful?