-- 007_podium.sql — add podium to finished_races. -- -- Podium is the top-3 finishers of a completed race. Stored as JSONB -- (a small ordered list, rarely queried as a relation). Shape per row: -- { "position": 1, "driver_id": "driver-alice", -- "name": "driver-alice", "total_time_ms": 123456 } -- -- Ordering: position 1 first. -- GIN index over the jsonb lets future UI filters (e.g. "races won by -- driver X") use @> containment queries without a schema change. ALTER TABLE finished_races ADD COLUMN IF NOT EXISTS podium JSONB NOT NULL DEFAULT '[]'::jsonb; CREATE INDEX IF NOT EXISTS finished_races_podium_gin ON finished_races USING GIN (podium);