I cant create Accounts
Hello dear Community, I am a newbie in Programming so I dont know much, im creating a App with the help of lovable but everytime I try to create a Account in supabase or in loveable it Doesnt work; Database error creating new user. I tried with some sql Commands with the help of Chat gpt: • Created profiles table with id, user_id, full_name, created_at
• Enabled RLS on profiles
• Deleted old overlapping policies; added clean INSERT, SELECT, UPDATE policies
• Tried trigger on auth.users to auto-create profile → failed due to NOT NULL columns
• Removed trigger; kept only SELECT/UPDATE policies → still “Database error creating new user”
• Identified causes: RLS blocking inserts, NOT NULL fields, Supabase Auth misconfiguration (email sign-ups, Google OAuth, SMTP)
• Proposed clean approach:
1. Remove triggers
2. Create user in Supabase Auth first
3. Create profile afterward via frontend/backend code
• This method avoids trigger issues, respects RLS, and allows email + Google login to work correctly.
Can anyone help me ?
9 Replies
I'm confused by the start, are your errors trying to create a new user or trying to create a profile after a user is created?
Also it would help to know how you are currently creating users, are you doing it via the dashboard or are you trying to do it via code?
Hey so im doing it via: authentification > Add user . Than when I insert an email and a password a pop up appears: error 500: database error creating new user
and is this because you have a trigger that creates a profile after a user signs up but you have a colun that is non null?
I already tried to remove the trigger with a sql code but it wont work, do you have any suggestions, and im sorry if I don’t understand everything im new to this stuff
I tried this code : -- Profiles table
create table if not exists public.profiles (
id uuid primary key references auth.users(id),
user_id uuid not null,
full_name text null,
created_at timestamp with time zone default now()
);
-- Enable RLS
alter table public.profiles enable row level security;
-- Policies
create policy "user can insert own profile"
on public.profiles
for insert
with check (auth.uid() = user_id);
create policy "user can select own profile"
on public.profiles
for select
using (auth.uid() = user_id);
create policy "user can update own profile"
on public.profiles
for update
using (auth.uid() = user_id)
with check (auth.uid() = user_id);
-- Remove triggers
drop trigger if exists create_profile_after_signup on auth.users;
One issue you might have is you have both id and user_id. They likely should be just id as it is the UUID of the auth.user according to your table definition. Your policies are all on user_id so it would need to get populated. But then your id also has to be populated as it is an FK link to auth.users.
How you populate the table is the open question.
You appear to have dropped on trigger. Do you have others?
Check the dashboard/database/trigger tab and select auth schema. See if you have other triggers.
Your beginning error database error implies you DO have a trigger function running.
You can also look in the Postgres log for more information on the error.
I only have 3 triggers: update_conversations_updated_at, update_friend_requests_updated_at, update_profiles_updated_at. But nothing seems to associate with my problem unless im stupid
If all of those are on auth.users then any of them could cause the issue.
But how can I fix this ?
You have to find the bug in your code in one of those three functions.
Either by trial and error IF they are all on auth.users (you did not say) by removing them one at a time OR by looking at the error details in the Postgres log to determine which function is getting the error.