Conversation
Resume logic was consolidated into the tournament triggers in 34a0a78.
- can_cancel_match: gate cancel button on privileged roles for Admin mode - tbu_matches: raise exception for unprivileged cancel in Admin mode - tournament_brackets: remove nested DECLARE/BEGIN/END, reuse existing var
When teams join a tournament with an existing team, tournament_teams.name is NULL. The get_team_name function now falls back to the linked teams.name via tournament_teams.team_id instead of showing the captain's name.
…nament_finished - T1 (Adria Cup): add missing parent_bracket_id linking SF1/SF2 to Final - T2 (Balkan Masters): restructure 6-team bracket with byes for top 2 seeds (3 R1 + 2 R2 + Final → 2 R1 + 2 R2 + Final, removing orphaned R1M3) - check_tournament_finished: skip status update when tournament is Paused, Cancelled, or CancelledMinTeams
…ed matches Add scheduled_at column so organizers can set match times on pending brackets while a tournament is paused. schedule_tournament_match() now uses COALESCE(bracket.scheduled_at, now()) and ETA calculation respects the organizer-set schedule across all stage types.
- Clamp scheduled_at to now() on tournament resume to prevent stale timestamps - Simplify can_pause/can_resume by removing redundant role checks (is_tournament_organizer covers them) - Add trailing newline to check_tournament_finished.sql
lukepolo
left a comment
There was a problem hiding this comment.
I messed up giving the requirements, and am changing them on you a bit.
1. e_match_mode Table
The e_match_mode table defines how a match is started/scheduled.
Schema
value(string, primary key)description(string, required)
Allowed Values
value description
admin Match must be scheduled and started by an admin user
auto Match is automatically scheduled by the system
No cancellation logic should exist in this table.
2. match_options Table Changes
Two new columns must be added to match_options.
Migration
ALTER TABLE match_options
ADD COLUMN match_mode VARCHAR NOT NULL REFERENCES e_match_mode(value),
ADD COLUMN track_cancellation BOOLEAN NOT NULL DEFAULT TRUE;3. Column Definitions
match_mode
Foreign key reference to e_match_mode(value).
Controls who or what starts the match:
admin→ must be started by an adminauto→ automatically started by the system
track_cancellation
Boolean flag controlling whether canceled_at is recorded.
TRUE→ system setscanceled_atwhen canceledFALSE→ system does NOT setcanceled_at
4. Behavior Matrix
match_mode track_cancellation Behavior
admin true Admin start, auto cancellation
admin false Admin start, cancellation ignored
auto true Auto start, auto cancellation
auto false Auto start, cancellation ignored
…el/tournament logic - Add joined_tournament computed field to guest and user select_permissions on tournaments table to fix Hasura 'field not found' errors - Refine auto-cancel, tournament pause/resume, and round-robin scheduling - Add migrations for auto_start column and auto_cancel replacement
Extract the duplicated tournament pause/auto_start check from schedule_next_round_robin_matches and tournament_brackets trigger into a shared should_auto_schedule() function.
Address PR review: redesign auto_cancel boolean into two fields - match_mode (admin/auto enum) and track_cancellation (boolean). Revert check_tournament_finished guard, remove pause-clearing logic from match_maps trigger, squash migrations into clean schema.
- 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
… should_auto_schedule Add explicit auto_start to all tournament INSERTs (T3 uses false for admin-managed coverage). Set match_mode='admin' on T3 match_options to exercise the non-default path. Wrap should_auto_schedule return in COALESCE to guard against NULL tournament lookups.
…duration overrides Add auto_cancel_duration and live_match_timeout nullable columns to match_options. Update tbu_matches and tbu_match_maps triggers to use COALESCE override pattern, replacing hardcoded 3-hour live timeout with configurable live_match_timeout.
…lation rename and override columns
The prior migration already creates the column as match_cancellation, so the rename statement fails. Keep only the ADD COLUMN statements.
…s on duration columns
Prevents auto-cancel timer from expiring while a match is paused. On pause: clears cancels_at. On resume to Live/Overtime: resets cancels_at with live_match_timeout if match_cancellation is enabled.
| @@ -0,0 +1,3 @@ | |||
| ALTER TABLE public.match_options | |||
| ADD COLUMN match_mode text NOT NULL DEFAULT 'auto' REFERENCES public.e_match_mode(value), | |||
| ADD COLUMN match_cancellation boolean NOT NULL DEFAULT true; | |||
There was a problem hiding this comment.
lets change to auto_cancellation,
There was a problem hiding this comment.
this should not be a thing
One thing to check here with you: the spec describes track_cancellation as controlling whether canceled_at is recorded. The current implementation uses it to control whether cancels_at is set - example - it toggles the auto-cancel timer, not just the timestamp. So when auto_cancellation = false, the match won't get an auto-cancel deadline at all. Is that the intended behavior, or should we only suppress the recording of canceled_at? |
…me collision The migration adding auto_cancel_duration column to match_options caused ambiguous column reference errors in triggers that had a local variable with the same name.
No description provided.