teecup/041_chapman_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

25 lines
1.5 KiB
SQL

-- =====================================================================
-- TeeCup — Chapman/Pinehurst ("Try all"), migrasjon 041. Første av åtte
-- nye turneringsformater denne runden (se plan/ADR for full liste og
-- begrunnelse). Chapman er strukturelt IDENTISK med eksisterende
-- foursome (delt ball, én score per hull per side, CombinedPercentage
-- 50%) -- reglene om hvem som slår hvilket slag (bytt utslag, velg
-- beste 2. slag, spilleren som ikke ble valgt slår 3. slag, deretter
-- alternerer de) er ren gameplay-etikette som foursome heller ikke
-- sporer noe sted -- ingen ny motorlogikk, kun et nytt formatnavn som
-- ALIASES til foursome (se app/handicap.py sin nye
-- ENGINE_FORMAT_ALIASES og rounds.py sin _ROUND_FORMAT_TO_ENGINE_FORMAT).
--
-- To separate CHECK-utvidelser: round.play_format (frittstående runder)
-- OG session.format (org-lagturneringer) -- Chapman er ALDRI aktuelt for
-- den individuelle org-modellen (ADR-037), kun to-siders formater.
-- =====================================================================
\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'));
ALTER TABLE session DROP CONSTRAINT session_format_check;
ALTER TABLE session ADD CONSTRAINT session_format_check
CHECK (format IN ('singles', 'fourball', 'foursome', 'greensome', 'scramble_2', 'scramble_4', 'chapman'));