'upsert in psql with more than one confliclt pk and unique

will we i should use on conflict but th scenario is kinda weird

create table lookup(
  id GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  name varchar(50) not null unique
);

2 conflicts may accrue

  • dub pk
  • name not unique

on conflict should add the next vacant id yet i may max() AND the unique constraint should be ignored



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source