Skip to content

Commit 324f122

Browse files
committed
fix: enforce match_mode guard and drop leftover e_auto_cancel_mode
- Add early-return in schedule_tournament_match when match_mode = 'admin' to prevent auto-scheduling of admin-only matches - Add cleanup migration to drop e_auto_cancel_mode table from prior dev runs
1 parent a46d305 commit 324f122

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

hasura/functions/tournaments/schedule_tournament_match.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ CREATE OR REPLACE FUNCTION public.schedule_tournament_match(bracket public.tourn
5555
_match_options_id := tournament.match_options_id;
5656
END IF;
5757

58+
-- Enforce match_mode: skip auto-scheduling for admin-only matches
59+
DECLARE
60+
_match_mode text;
61+
BEGIN
62+
SELECT mo.match_mode INTO _match_mode
63+
FROM match_options mo WHERE mo.id = _match_options_id;
64+
65+
IF _match_mode = 'admin' THEN
66+
RETURN NULL;
67+
END IF;
68+
END;
69+
5870
-- Per-round best_of resolution (only when bracket has no custom match_options)
5971
IF bracket.match_options_id IS NULL THEN
6072
IF stage.type = 'Swiss' THEN
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE IF NOT EXISTS public.e_auto_cancel_mode (
2+
value text NOT NULL PRIMARY KEY,
3+
description text NOT NULL
4+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS public.e_auto_cancel_mode;

0 commit comments

Comments
 (0)