Fix · Supabase and databases
duplicate key value violates unique constraint (23505)
What you may see
- Saving fails because something with the same value already exists
Most likely cause
A column that must be unique (an email, a slug, an order number) already holds this value.
Check first (about two minutes)
- Read the constraint name in the message: it tells which column.
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Find which column and which existing row clash.
- Decide with me: update the existing row (upsert), choose another value, or show a friendly message.
- Make the code handle this error with a clear message.
Do not do this
- Do not delete the old row without checking what depends on it.
- Do not remove the unique rule.