Postgres on conflict do update on composite primary keys
Just place both keys in the ON CONFLICT clause: INSERT INTO answer VALUES (1,1,’q1′) ON CONFLICT (person_id,question_id) DO UPDATE SET answer = EXCLUDED.answer; Example: INSERT INTO answer VALUES (1,1,’q1′) ON CONFLICT (person_id,question_id) DO UPDATE SET answer = EXCLUDED.answer; SELECT * FROM answer; person_id | question_id | answer ———–+————-+——– 1 | 1 | q1 (1 Zeile) … Read more