-- Season history: one row per completed season
CREATE TABLE IF NOT EXISTS season_history (
    id          TEXT PRIMARY KEY,
    profile_id  TEXT NOT NULL,
    season_number INTEGER NOT NULL,
    division    INTEGER NOT NULL,
    season_points INTEGER NOT NULL,
    wins        INTEGER NOT NULL,
    draws       INTEGER NOT NULL,
    losses      INTEGER NOT NULL,
    result      TEXT NOT NULL,   -- 'promoted' | 'maintained' | 'relegated'
    new_division INTEGER NOT NULL,
    coins_awarded INTEGER NOT NULL,
    pack_awarded TEXT,            -- nullable
    ended_at    TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_season_history_profile ON season_history (profile_id, season_number DESC);
