teecup/045_flag_round_format.sql
Erol Haagenrud 7ae554062c All eight new turneringsformater have backend + engine complete and scratch-verified — Chapman, Nassau, Københavner, Bingo Bango Bongo, Flaggturnering, Shamble, Money Ball, and High-low-high. Built and tested one format at a time (engine tests → migration → API wiring → scratch verification) exactly per the approved plan:
Verification totals: handicap_engine.py unit tests went from 63 → 98 (all passing), plus 400+ scratch-API checks across the eight formats' test scripts, covering both frittstående runder and the appropriate org-scoped system (team or individual) for each. test_isolation.sql stayed 12/12 throughout — migrations 041–050 are purely additive.

A few real things surfaced and were fixed during testing:

Nassau can be blocked by the existing "match already decided" lock (ADR-012) if the overall 18-hole match closes early — documented as a known v1 limitation, not fixed (would mean loosening an established safety guard).
Københavner's points depend on all 3 players at once, breaking the usual "recompute one participant" pattern — handled with a dedicated recompute path.
High-low-high doesn't fit the existing win/loss/halved match cache, so it gets its own dedicated read endpoint (like Nassau) — verified digit-for-digit against your own worked example ("1-1 etter hull 1", "2-1 til lag 2").
Two missing-column crashes (caught in scratch, never reached anything resembling "done").
2026-07-30 14:54:11 +02:00

19 lines
1.1 KiB
SQL

-- =====================================================================
-- TeeCup — Flaggturnering/Flag tournament (frittstående runder),
-- migrasjon 045. Femte av åtte nye turneringsformater denne runden.
--
-- Flatt felt, individuelt, INGEN sider. Gjenbruker EKSISTERENDE
-- individuell-ball round_hole-lagring og round_participant.course_
-- handicap_snapshot (allerede beregnet ved deltaker-opprettelse for
-- ALLE formater, se _create_participant) -- INGEN nye kolonner. Par +
-- course handicap gir et fast slag-budsjett for runden; flagget plantes
-- der spilleren går tom (handicap_engine.py sin flag_result).
--
-- v1: hull-granularitet (ikke sub-hull/GPS -- bevisst utenfor omfang),
-- ingen fortsettelse på hull 19+.
-- =====================================================================
\set ON_ERROR_STOP on
ALTER TABLE round DROP CONSTRAINT round_play_format_check;
ALTER TABLE round ADD CONSTRAINT round_play_format_check
CHECK (play_format IN ('stroke', 'match', 'skins', 'fourball', 'foursome', 'greensome', 'scramble_2', 'scramble_4', 'stableford', 'chapman', 'copenhagen', 'bbb', 'flag'));