* feat: EV simulation framework with F1 Monte Carlo simulator - Add EV snapshot tables (participant_ev_snapshots, team_ev_snapshots) and simulation_status column on sports seasons - Add ev-snapshot model with upsert and history query functions - Add simulator framework: types, bracket/F1/golf simulators, registry - F1 simulator: vig-removed ICM weighted draw (pre-season) + race-by-race Monte Carlo from current standings (in-season); per-position column normalization to prevent floating-point EV drift - Add admin simulate route and Run Simulation button on sports season page - Rework futures-odds admin page to save odds then run simulation in one action - Remove recalculate-probabilities route (superseded by simulate route) - Remove EV trend chart panel and associated DB queries Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: map simulators to sports via simulatorType field Adds a `simulator_type` enum column to the `sports` table so each sport can be assigned a specific simulation algorithm rather than deriving it from the sports season's scoring pattern. - Add `simulatorTypeEnum` (f1_standings, indycar_standings, golf_qualifying_points, playoff_bracket) + `simulatorType` nullable column on `sports` table; migration 0037 - Rewrite simulator registry to key off `SimulatorType` instead of `ScoringPattern`; indycar_standings shares F1Simulator for now - `findSportsSeasonById` now returns `SportsSeasonWithSport` so callers have typed access to `sport.simulatorType` - Simulate and futures-odds actions read `sport.simulatorType`; guard fires before setting `simulationStatus: running` - Admin sport edit page gains a Simulator Type dropdown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
1.2 KiB
SQL
31 lines
1.2 KiB
SQL
-- Consolidate single_elimination_playoff and page_playoff → playoff_bracket
|
|
-- PostgreSQL does not support DROP VALUE on enums, so we recreate the type.
|
|
-- Wrapped in DO block so re-running is safe if already applied.
|
|
|
|
DO $$
|
|
BEGIN
|
|
-- Only migrate if the old enum values still exist
|
|
IF EXISTS (
|
|
SELECT 1 FROM pg_enum
|
|
WHERE enumlabel = 'single_elimination_playoff'
|
|
AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'scoring_pattern')
|
|
) THEN
|
|
-- Step 1: Create new consolidated enum
|
|
CREATE TYPE "scoring_pattern_new" AS ENUM('playoff_bracket', 'season_standings', 'qualifying_points');
|
|
|
|
-- Step 2: Migrate column data, mapping old values to playoff_bracket
|
|
ALTER TABLE "sports_seasons"
|
|
ALTER COLUMN "scoring_pattern" TYPE "scoring_pattern_new"
|
|
USING (
|
|
CASE scoring_pattern::text
|
|
WHEN 'single_elimination_playoff' THEN 'playoff_bracket'::scoring_pattern_new
|
|
WHEN 'page_playoff' THEN 'playoff_bracket'::scoring_pattern_new
|
|
ELSE scoring_pattern::text::scoring_pattern_new
|
|
END
|
|
);
|
|
|
|
-- Step 3: Replace old type
|
|
DROP TYPE "scoring_pattern";
|
|
ALTER TYPE "scoring_pattern_new" RENAME TO "scoring_pattern";
|
|
END IF;
|
|
END $$;
|