Skip to content

Commit b62f5a5

Browse files
committed
bug: fix issue with match map demos being attached
1 parent 3805ac7 commit b62f5a5

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • hasura/migrations/default/1761617285280_alter_table_public_match_map_veto_picks_add_unique_match_id_map_id
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
DROP TRIGGER IF EXISTS tbd_match_map_veto_picks ON public.match_map_veto_picks;
2+
13
WITH duplicates AS (
24
SELECT
3-
id,
5+
mmvp.id,
46
ROW_NUMBER() OVER (
5-
PARTITION BY match_id, map_id
6-
ORDER BY created_at ASC, id ASC
7+
PARTITION BY mmvp.match_id, mmvp.map_id
8+
ORDER BY
9+
CASE WHEN EXISTS (
10+
SELECT 1 FROM match_maps mm
11+
JOIN match_map_demos mmd ON mmd.match_map_id = mm.id
12+
WHERE mm.match_id = mmvp.match_id AND mm.map_id = mmvp.map_id
13+
) THEN 0 ELSE 1 END,
14+
mmvp.created_at ASC,
15+
mmvp.id ASC
716
) as row_num
8-
FROM match_map_veto_picks
17+
FROM match_map_veto_picks mmvp
918
)
1019
DELETE FROM match_map_veto_picks
1120
WHERE id IN (
@@ -14,4 +23,6 @@ WHERE id IN (
1423
WHERE row_num > 1
1524
);
1625

26+
CREATE TRIGGER tbd_match_map_veto_picks BEFORE DELETE ON public.match_map_veto_picks FOR EACH ROW EXECUTE FUNCTION public.tbd_match_map_veto_picks();
27+
1728
alter table "public"."match_map_veto_picks" add constraint "match_map_veto_picks_match_id_map_id_key" unique ("match_id", "map_id");

0 commit comments

Comments
 (0)