I want to increment search counter when user searches a word.
create table public."SearchLog" (
id integer primary key not null default nextval('"SearchLog_id_seq"'::regclass),
search character varying(192),
replacement character varying(192),
qty integer,
visible boolean,
created_at timestamp(3) without time zone default CURRENT_TIMESTAMP(3),
updated_at timestamp(3) without time zone default CURRENT_TIMESTAMP(3)
);
when i run the code
insert into "SearchLog" (search)
values ('test')
on conflict(search) do update set qty = excluded.qty + 1,
updated_at = current_timestamp(3);
i get this error:
[23505] ERROR: duplicate key value violates unique constraint "SearchLog_pkey"
why "on coflict" doesn't trigger? how it can violates pkey if i even didn't provided it?