CREATE UNIQUE INDEX a_cart_offer_user_unique
ON cart
USING btree(offer_id, user_id)
WHERE order_id IS NULL
id | 5557
user_id | 15
offer_id | 526
order_id | 15446
я пытаюсь выполнить INSERT INTO "cart" ("user_id", "offer_id", "order_id")
VALUES (15, 526, NULL)
[23505] ERROR: duplicate key value violates unique constraint "a_cart_offer_user_unique": Key (offer_id, user_id)=(526, 15) already exists.