felt/internal/store/migrations/007_deal_proposals.sql
Mikkel Georgsen 75ccb6f735 feat(01-09): implement tournament lifecycle, multi-tournament, ICM, and chop/deal
- TournamentService with create-from-template, start, pause, resume, end, cancel
- Auto-close when 1 player remains, with CheckAutoClose hook
- TournamentState aggregation for WebSocket full-state snapshot
- ActivityEntry feed converting audit entries to human-readable items
- MultiManager with ListActiveTournaments for lobby view (MULTI-01/02)
- ICM calculator: exact Malmuth-Harville for <=10, Monte Carlo for 11+ (FIN-11)
- ChopEngine with ICM, chip-chop, even-chop, custom, and partial-chop deals
- DealProposal workflow: propose, confirm, cancel with audit trail
- Tournament API routes for lifecycle, state, activity, and deal endpoints
- deal_proposals migration (007) for storing chop proposals

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 07:58:11 +01:00

21 lines
1,017 B
SQL

-- Deal/chop proposals table for tournament end-game scenarios.
-- Proposals are created, reviewed by the TD, then confirmed or cancelled.
CREATE TABLE IF NOT EXISTS deal_proposals (
id TEXT PRIMARY KEY,
tournament_id TEXT NOT NULL REFERENCES tournaments(id) ON DELETE CASCADE,
deal_type TEXT NOT NULL CHECK (deal_type IN (
'icm', 'chip_chop', 'even_chop', 'custom', 'partial_chop'
)),
payouts TEXT NOT NULL DEFAULT '[]', -- JSON array of DealPayout
total_amount INTEGER NOT NULL DEFAULT 0, -- cents
is_partial INTEGER NOT NULL DEFAULT 0,
remaining_pool INTEGER NOT NULL DEFAULT 0, -- cents, for partial chop
status TEXT NOT NULL DEFAULT 'proposed' CHECK (status IN (
'proposed', 'confirmed', 'cancelled'
)),
created_at INTEGER NOT NULL DEFAULT (unixepoch())
);
CREATE INDEX IF NOT EXISTS idx_deal_proposals_tournament ON deal_proposals(tournament_id);
CREATE INDEX IF NOT EXISTS idx_deal_proposals_status ON deal_proposals(tournament_id, status);