I have to unique constraint set in my table structure. One of them is a set of (store_id, cart_id, product_id)
and the other one is (warehouse_id, cart_id, product_id)
I'm trying to upsert products using ON CONFLICT clause in SQL like below.
insert into "public"."cart_items" ("cart_id", "product_id", "quantity", "unit_sell_price", "warehouse_id") values (7, 19340, 41, 184.25145454, 1)
ON CONFLICT (store_id, cart_id, product_id)
DO UPDATE SET
discount = EXCLUDED.discount,
coupon_id = EXCLUDED.coupon_id,
unit_sell_price = EXCLUDED.unit_sell_price,
quantity = EXCLUDED.quantity,
meta = EXCLUDED.meta,
cart_id = EXCLUDED.cart_id
RETURNING *;
I know how to handle it for a single constraint like above, but how can I check for both constraint sets? like ON CONFLICT (store_id, cart_id, product_id) OR (warehouse, cart_id, product_id)