felt/internal/store/migrations/005_builtin_templates.sql
Mikkel Georgsen 7dbb4cab1a feat(01-05): add built-in templates, seed data, wizard tests, and template tests
- Built-in blind structures: Turbo (15min), Standard (20min), Deep Stack (30min), WSOP-style (60min, BB ante)
- Built-in payout structure: Standard with 4 entry-count brackets (8-20, 21-30, 31-40, 41+)
- Built-in buy-in configs: Basic 200 DKK through WSOP 1000 DKK with rake splits
- 4 built-in tournament templates composing above building blocks
- 005_builtin_templates.sql seed migration (INSERT OR IGNORE, safe to re-run)
- Wizard tests: standard, various player counts, denomination alignment, edge cases
- Template tests: create/expand/duplicate/save-as/delete-builtin/list

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

192 lines
10 KiB
SQL

-- 005_builtin_templates.sql
-- Built-in blind structures, payout structures, buy-in configs, and tournament templates.
-- All marked is_builtin = 1, cannot be deleted, can be duplicated.
-- Uses INSERT OR IGNORE so re-running is safe.
-- =============================================================================
-- Built-in Blind Structures
-- =============================================================================
-- Turbo (~2hr for 20 players, 15-min levels, starting chips 10000)
INSERT OR IGNORE INTO blind_structures (id, name, is_builtin, game_type_default, notes) VALUES
(1, 'Turbo', 1, 'nlhe', '~2hr for 20 players, 15-min levels, starting chips 10,000');
INSERT OR IGNORE INTO blind_levels (structure_id, position, level_type, game_type, small_blind, big_blind, ante, bb_ante, duration_seconds, notes) VALUES
(1, 0, 'round', 'nlhe', 25, 50, 0, 0, 900, ''),
(1, 1, 'round', 'nlhe', 50, 100, 0, 0, 900, ''),
(1, 2, 'round', 'nlhe', 75, 150, 0, 0, 900, ''),
(1, 3, 'round', 'nlhe', 100, 200, 0, 0, 900, ''),
(1, 4, 'break', 'nlhe', 0, 0, 0, 0, 600, ''),
(1, 5, 'round', 'nlhe', 150, 300, 300, 0, 900, ''),
(1, 6, 'round', 'nlhe', 200, 400, 400, 0, 900, ''),
(1, 7, 'round', 'nlhe', 300, 600, 600, 0, 900, ''),
(1, 8, 'round', 'nlhe', 400, 800, 800, 0, 900, ''),
(1, 9, 'break', 'nlhe', 0, 0, 0, 0, 600, ''),
(1, 10, 'round', 'nlhe', 600, 1200, 1200, 0, 900, ''),
(1, 11, 'round', 'nlhe', 800, 1600, 1600, 0, 900, ''),
(1, 12, 'round', 'nlhe', 1000, 2000, 2000, 0, 900, ''),
(1, 13, 'round', 'nlhe', 1500, 3000, 3000, 0, 900, ''),
(1, 14, 'round', 'nlhe', 2000, 4000, 4000, 0, 900, '');
-- Standard (~3-4hr for 20 players, 20-min levels, starting chips 15000)
INSERT OR IGNORE INTO blind_structures (id, name, is_builtin, game_type_default, notes) VALUES
(2, 'Standard', 1, 'nlhe', '~3-4hr for 20 players, 20-min levels, starting chips 15,000');
INSERT OR IGNORE INTO blind_levels (structure_id, position, level_type, game_type, small_blind, big_blind, ante, bb_ante, duration_seconds, notes) VALUES
(2, 0, 'round', 'nlhe', 25, 50, 0, 0, 1200, ''),
(2, 1, 'round', 'nlhe', 50, 100, 0, 0, 1200, ''),
(2, 2, 'round', 'nlhe', 75, 150, 0, 0, 1200, ''),
(2, 3, 'round', 'nlhe', 100, 200, 0, 0, 1200, ''),
(2, 4, 'round', 'nlhe', 150, 300, 0, 0, 1200, ''),
(2, 5, 'break', 'nlhe', 0, 0, 0, 0, 600, ''),
(2, 6, 'round', 'nlhe', 200, 400, 400, 0, 1200, ''),
(2, 7, 'round', 'nlhe', 300, 600, 600, 0, 1200, ''),
(2, 8, 'round', 'nlhe', 400, 800, 800, 0, 1200, ''),
(2, 9, 'round', 'nlhe', 500, 1000, 1000, 0, 1200, ''),
(2, 10, 'break', 'nlhe', 0, 0, 0, 0, 600, ''),
(2, 11, 'round', 'nlhe', 600, 1200, 1200, 0, 1200, ''),
(2, 12, 'round', 'nlhe', 800, 1600, 1600, 0, 1200, ''),
(2, 13, 'round', 'nlhe', 1000, 2000, 2000, 0, 1200, ''),
(2, 14, 'round', 'nlhe', 1500, 3000, 3000, 0, 1200, ''),
(2, 15, 'round', 'nlhe', 2000, 4000, 4000, 0, 1200, ''),
(2, 16, 'round', 'nlhe', 3000, 6000, 6000, 0, 1200, '');
-- Deep Stack (~5-6hr for 20 players, 30-min levels, starting chips 25000)
INSERT OR IGNORE INTO blind_structures (id, name, is_builtin, game_type_default, notes) VALUES
(3, 'Deep Stack', 1, 'nlhe', '~5-6hr for 20 players, 30-min levels, starting chips 25,000');
INSERT OR IGNORE INTO blind_levels (structure_id, position, level_type, game_type, small_blind, big_blind, ante, bb_ante, duration_seconds, notes) VALUES
(3, 0, 'round', 'nlhe', 25, 50, 0, 0, 1800, ''),
(3, 1, 'round', 'nlhe', 50, 100, 0, 0, 1800, ''),
(3, 2, 'round', 'nlhe', 75, 150, 0, 0, 1800, ''),
(3, 3, 'round', 'nlhe', 100, 200, 0, 0, 1800, ''),
(3, 4, 'round', 'nlhe', 150, 300, 0, 0, 1800, ''),
(3, 5, 'break', 'nlhe', 0, 0, 0, 0, 900, ''),
(3, 6, 'round', 'nlhe', 200, 400, 0, 0, 1800, ''),
(3, 7, 'round', 'nlhe', 250, 500, 500, 0, 1800, ''),
(3, 8, 'round', 'nlhe', 300, 600, 600, 0, 1800, ''),
(3, 9, 'round', 'nlhe', 400, 800, 800, 0, 1800, ''),
(3, 10, 'break', 'nlhe', 0, 0, 0, 0, 900, ''),
(3, 11, 'round', 'nlhe', 500, 1000, 1000, 0, 1800, ''),
(3, 12, 'round', 'nlhe', 600, 1200, 1200, 0, 1800, ''),
(3, 13, 'round', 'nlhe', 800, 1600, 1600, 0, 1800, ''),
(3, 14, 'round', 'nlhe', 1000, 2000, 2000, 0, 1800, ''),
(3, 15, 'break', 'nlhe', 0, 0, 0, 0, 900, ''),
(3, 16, 'round', 'nlhe', 1500, 3000, 3000, 0, 1800, ''),
(3, 17, 'round', 'nlhe', 2000, 4000, 4000, 0, 1800, ''),
(3, 18, 'round', 'nlhe', 3000, 6000, 6000, 0, 1800, ''),
(3, 19, 'round', 'nlhe', 4000, 8000, 8000, 0, 1800, ''),
(3, 20, 'round', 'nlhe', 5000, 10000,10000,0, 1800, '');
-- WSOP-style (60-min levels, BB ante from level 4, starting chips 50000)
INSERT OR IGNORE INTO blind_structures (id, name, is_builtin, game_type_default, notes) VALUES
(4, 'WSOP-style', 1, 'nlhe', '60-min levels, BB ante from level 4, starting chips 50,000');
INSERT OR IGNORE INTO blind_levels (structure_id, position, level_type, game_type, small_blind, big_blind, ante, bb_ante, duration_seconds, notes) VALUES
(4, 0, 'round', 'nlhe', 25, 50, 0, 0, 3600, ''),
(4, 1, 'round', 'nlhe', 50, 100, 0, 0, 3600, ''),
(4, 2, 'round', 'nlhe', 75, 150, 0, 0, 3600, ''),
(4, 3, 'round', 'nlhe', 100, 200, 0, 200, 3600, 'BB ante starts'),
(4, 4, 'break', 'nlhe', 0, 0, 0, 0, 1200, ''),
(4, 5, 'round', 'nlhe', 150, 300, 0, 300, 3600, ''),
(4, 6, 'round', 'nlhe', 200, 400, 0, 400, 3600, ''),
(4, 7, 'round', 'nlhe', 250, 500, 0, 500, 3600, ''),
(4, 8, 'round', 'nlhe', 300, 600, 0, 600, 3600, ''),
(4, 9, 'break', 'nlhe', 0, 0, 0, 0, 1200, ''),
(4, 10, 'round', 'nlhe', 400, 800, 0, 800, 3600, ''),
(4, 11, 'round', 'nlhe', 500, 1000, 0, 1000,3600, ''),
(4, 12, 'round', 'nlhe', 600, 1200, 0, 1200,3600, ''),
(4, 13, 'round', 'nlhe', 800, 1600, 0, 1600,3600, ''),
(4, 14, 'break', 'nlhe', 0, 0, 0, 0, 1200, ''),
(4, 15, 'round', 'nlhe', 1000, 2000, 0, 2000,3600, ''),
(4, 16, 'round', 'nlhe', 1500, 3000, 0, 3000,3600, ''),
(4, 17, 'round', 'nlhe', 2000, 4000, 0, 4000,3600, ''),
(4, 18, 'round', 'nlhe', 2500, 5000, 0, 5000,3600, ''),
(4, 19, 'round', 'nlhe', 3000, 6000, 0, 6000,3600, '');
-- =============================================================================
-- Built-in Payout Structure (Standard)
-- =============================================================================
INSERT OR IGNORE INTO payout_structures (id, name, is_builtin) VALUES
(1, 'Standard', 1);
-- Bracket: 8-20 entries (3 prizes: 50/30/20)
INSERT OR IGNORE INTO payout_brackets (id, structure_id, min_entries, max_entries) VALUES (1, 1, 8, 20);
INSERT OR IGNORE INTO payout_tiers (bracket_id, position, percentage_basis_points) VALUES
(1, 1, 5000),
(1, 2, 3000),
(1, 3, 2000);
-- Bracket: 21-30 entries (4 prizes: 45/26/17/12)
INSERT OR IGNORE INTO payout_brackets (id, structure_id, min_entries, max_entries) VALUES (2, 1, 21, 30);
INSERT OR IGNORE INTO payout_tiers (bracket_id, position, percentage_basis_points) VALUES
(2, 1, 4500),
(2, 2, 2600),
(2, 3, 1700),
(2, 4, 1200);
-- Bracket: 31-40 entries (5 prizes: 40/24/15/12/9)
INSERT OR IGNORE INTO payout_brackets (id, structure_id, min_entries, max_entries) VALUES (3, 1, 31, 40);
INSERT OR IGNORE INTO payout_tiers (bracket_id, position, percentage_basis_points) VALUES
(3, 1, 4000),
(3, 2, 2400),
(3, 3, 1500),
(3, 4, 1200),
(3, 5, 900);
-- Bracket: 41+ entries (6 prizes: 35/22/14/12/9/8)
INSERT OR IGNORE INTO payout_brackets (id, structure_id, min_entries, max_entries) VALUES (4, 1, 41, 999);
INSERT OR IGNORE INTO payout_tiers (bracket_id, position, percentage_basis_points) VALUES
(4, 1, 3500),
(4, 2, 2200),
(4, 3, 1400),
(4, 4, 1200),
(4, 5, 900),
(4, 6, 800);
-- =============================================================================
-- Built-in Buy-in Configs
-- =============================================================================
-- Basic buy-in (200 DKK buyin, 10000 starting chips, 20 DKK rake)
INSERT OR IGNORE INTO buyin_configs (id, name, buyin_amount, starting_chips, rake_total) VALUES
(1, 'Basic (200 DKK)', 20000, 10000, 2000);
INSERT OR IGNORE INTO rake_splits (buyin_config_id, category, amount) VALUES
(1, 'house', 2000);
-- Standard buy-in (300 DKK, 15000 chips, 30 DKK rake)
INSERT OR IGNORE INTO buyin_configs (id, name, buyin_amount, starting_chips, rake_total) VALUES
(2, 'Standard (300 DKK)', 30000, 15000, 3000);
INSERT OR IGNORE INTO rake_splits (buyin_config_id, category, amount) VALUES
(2, 'house', 2000),
(2, 'staff', 1000);
-- Deep Stack buy-in (500 DKK, 25000 chips, 50 DKK rake)
INSERT OR IGNORE INTO buyin_configs (id, name, buyin_amount, starting_chips, rake_total) VALUES
(3, 'Deep Stack (500 DKK)', 50000, 25000, 5000);
INSERT OR IGNORE INTO rake_splits (buyin_config_id, category, amount) VALUES
(3, 'house', 3000),
(3, 'staff', 2000);
-- WSOP-style buy-in (1000 DKK, 50000 chips, 100 DKK rake)
INSERT OR IGNORE INTO buyin_configs (id, name, buyin_amount, starting_chips, rake_total) VALUES
(4, 'WSOP-style (1000 DKK)', 100000, 50000, 10000);
INSERT OR IGNORE INTO rake_splits (buyin_config_id, category, amount) VALUES
(4, 'house', 5000),
(4, 'staff', 3000),
(4, 'league', 2000);
-- =============================================================================
-- Built-in Tournament Templates
-- =============================================================================
INSERT OR IGNORE INTO tournament_templates (id, name, description, chip_set_id, blind_structure_id, payout_structure_id, buyin_config_id, min_players, is_builtin) VALUES
(1, 'Turbo', 'Fast tournament ~2hr for 20 players', 1, 1, 1, 1, 6, 1),
(2, 'Standard', 'Standard tournament ~3-4hr for 20 players', 1, 2, 1, 2, 6, 1),
(3, 'Deep Stack', 'Deep stack tournament ~5-6hr for 20 players', 1, 3, 1, 3, 6, 1),
(4, 'WSOP-style', 'Long tournament with BB ante and slow progression', 1, 4, 1, 4, 6, 1);