Given the table definition:
CREATE TABLE devices
(
id SERIAL PRIMARY KEY,
device_id TEXT NOT NULL,
device_name TEXT NOT NULL
);
CREATE UNIQUE INDEX devices_by_device_id_unique ON devices (device_id);
And this upsert:
INSERT INTO devices (device_id, device_name)
VALUES (:device_id, :device_name)
ON CONFLICT (device_id) DO UPDATE
SET device_name = :device_name
How is it possible to get the following error:
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "devices_pkey"
Detail: Key (id)=(253) already exists.
Since the id column is auto-generated, it shouldn't be possible to attempt to insert the same value twice?