teecup/048_money_ball_round.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

21 lines
1.3 KiB
SQL

-- =====================================================================
-- TeeCup — Money Ball/Lone Ranger (frittstående runder), migrasjon 048.
-- Sjuende av åtte nye turneringsformater denne runden.
--
-- Nøyaktig 4-manns lag. Samme "ett lag = hele runden, INGEN round_side"
-- -struktur som Shamble (bekreftet av bruker) -- flere lag som
-- konkurrerer settes opp som separate runder + flight_group_id.
--
-- Trenger en FAST spillerrekkefølge (round_participant.lineup_order,
-- 0-3) for å vite hvem som er "money ball" på hvilket hull -- et
-- konsept som ikke fantes noe sted i skjemaet fra før.
-- =====================================================================
\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', 'shamble', 'money_ball'));
ALTER TABLE round_participant ADD COLUMN lineup_order smallint CHECK (lineup_order IS NULL OR lineup_order BETWEEN 0 AND 3);
CREATE UNIQUE INDEX round_participant_lineup_order_unique
ON round_participant (round_id, lineup_order) WHERE lineup_order IS NOT NULL;