mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
fix(shop): resolve ambiguous column and missing unique constraint in RecordPurchase
The ON CONFLICT upsert referenced unqualified "bought" which PostgreSQL rejected as ambiguous, and the table lacked the UNIQUE constraint needed for ON CONFLICT. Adds a unique index on (character_id, shop_item_id) via migration 0003 and qualifies the column as shop_items_bought.bought.
This commit is contained in:
@@ -1220,6 +1220,9 @@ CREATE TABLE public.shop_items_bought (
|
||||
bought integer
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS shop_items_bought_character_item_unique
|
||||
ON public.shop_items_bought (character_id, shop_item_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: shop_items_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
|
||||
5
server/migrations/sql/0003_shop_items_bought_unique.sql
Normal file
5
server/migrations/sql/0003_shop_items_bought_unique.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
-- Add unique constraint required for ON CONFLICT upsert in RecordPurchase.
|
||||
-- Uses CREATE UNIQUE INDEX which supports IF NOT EXISTS, avoiding errors
|
||||
-- when the baseline schema (0001) already includes the constraint.
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS shop_items_bought_character_item_unique
|
||||
ON public.shop_items_bought (character_id, shop_item_id);
|
||||
Reference in New Issue
Block a user