No Unique or Exclusion Constraint Matching the on Conflict

How can I fix t here is no unique or exclusion constraint matching the ON CONFLICT specification when I have specified it?

You must have one matching unique constraint, not multiple overlapping unique constraints. The manual explains how this "unique index inference" is done.

Add

t.index ["campaign_id", "code", "code_id"], name: "unique_campaign_code_code_id", unique: true

and your query will work.

ERROR: pq: there is no unique or exclusion constraint matching the ON CONFLICT specification

There is no unique constraint on linkedin. Either create one, or use something else than INSERT ... ON CONFLICT.

POSTGRESQL: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

You are most likely missing a unique constraint on this particular field.

Example:

CREATE UNIQUE INDEX j_msgid_idx ON public.error_message((data->'jsonContent'->>'message_id'));

Postgres unique or exclusion constraint for partial index on conflict fails to update tickets

There is error message is the give away. Your on conflict constraint does not match any unique constraints declared against the table. ?

The column user_id exists along with other columns in your index ticket_user_id_not_completed_idx so there is no exact match. Your on conflict needs to match your index exactly. Either change your unique index to be just the user_id column or add all the columns to your on conflict clause.

Or

You can reference the constraint by name in the on conflict clause.

from the documentation



Related Topics



Leave a reply



Submit