Skip to content

Commit 3805ac7

Browse files
committed
bug: fix issue with duplicate maps being selected during the veto process
1 parent 7588dbd commit 3805ac7

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

  • hasura/migrations/default
    • 1761617285280_alter_table_public_match_map_veto_picks_add_unique_match_id_map_id
    • 1761617297952_alter_table_public_match_region_veto_picks_add_unique_match_id_region
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table "public"."match_map_veto_picks" drop constraint "match_map_veto_picks_match_id_map_id_key";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
WITH duplicates AS (
2+
SELECT
3+
id,
4+
ROW_NUMBER() OVER (
5+
PARTITION BY match_id, map_id
6+
ORDER BY created_at ASC, id ASC
7+
) as row_num
8+
FROM match_map_veto_picks
9+
)
10+
DELETE FROM match_map_veto_picks
11+
WHERE id IN (
12+
SELECT id
13+
FROM duplicates
14+
WHERE row_num > 1
15+
);
16+
17+
alter table "public"."match_map_veto_picks" add constraint "match_map_veto_picks_match_id_map_id_key" unique ("match_id", "map_id");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table "public"."match_region_veto_picks" drop constraint "match_region_veto_picks_match_id_region_key";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
WITH duplicates AS (
2+
SELECT
3+
id,
4+
ROW_NUMBER() OVER (
5+
PARTITION BY match_id, region
6+
ORDER BY created_at ASC, id ASC
7+
) as row_num
8+
FROM match_region_veto_picks
9+
)
10+
DELETE FROM match_region_veto_picks
11+
WHERE id IN (
12+
SELECT id
13+
FROM duplicates
14+
WHERE row_num > 1
15+
);
16+
17+
alter table "public"."match_region_veto_picks" add constraint "match_region_veto_picks_match_id_region_key" unique ("match_id", "region");

0 commit comments

Comments
 (0)