Error when signup and save data to profiles table
in my project, I am going to implement a multi-tenant feature.
but when I signup as a student, I got this error in browser console.
"there is no unique or exclusion constraint matching the ON CONFLICT specification"
so the user data is saved correctly in auth.users table but did not save in public profiles table
I attached error and the code section screenshot.


16 Replies
Are you sure that is the code running?
The on conflict part usually is associated with doing an Upsert.
I think this code is not working.
when I checked the browser console, I saw this error in 239 line.

I checked profiles table, but I think table structure is good, really dont know how to fix this conflict issue
I don't understand the on conflict error without an upsert.
But maybe it is just complaining about you inserting a duplicate key.... wild guess as this is not what the error says.
Do you have an insert trigger on the auth.users table to generate a profiles table row? Maybe you are trying to insert and it is already there.
Any trigger function on profiles table?
Have you ever had an upsert instead of insert to profiles table.
auth.users table, there is not any trigger
in profiles table, I saw this trigger


Should I update code from "insert" to "upsert"?
No. The ON CONFLICT Is part of UPSERT. That is why I don't understand why you are getting it.
Show that trigger function code if you can.
Also check the Postgres log for what is getting for the error.
okay, let me try
this is trigger function code

That is likely the source of your error.
Is the user_id column UNIQUE in that table?
yes, unique

in profiles table
The table the trigger is writing to
yeah, this trigger is used in profiles table
Did you find issue in my attached images?
It is inserting to user_statistics
With ON CONFLICT on user_id. That means user_id has to be a unique column in user_statistics
Or if you plan to have lots of rows of data for a user there, don't use ON CONFLICT
thanks, @garyaustin
when I check the user_statistics table, the is_UNIQUE is not set, so I set it and it worked!
Thank you so much!