-- NEO-47: per-player mastery branch picks and unlocked perk ids.
CREATE TABLE IF NOT EXISTS player_mastery_branch_pick (
    player_id TEXT NOT NULL REFERENCES player_position(player_id) ON DELETE CASCADE,
    skill_id TEXT NOT NULL,
    tier_index INTEGER NOT NULL CHECK (tier_index >= 1),
    branch_id TEXT NOT NULL,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    PRIMARY KEY (player_id, skill_id, tier_index)
);

CREATE TABLE IF NOT EXISTS player_unlocked_perk (
    player_id TEXT NOT NULL REFERENCES player_position(player_id) ON DELETE CASCADE,
    perk_id TEXT NOT NULL,
    unlocked_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    PRIMARY KEY (player_id, perk_id)
);

COMMENT ON TABLE player_mastery_branch_pick IS 'Mutually exclusive branch picks per mastery tier (NEO-47); tier 1 pick drives path-auto tier unlocks.';
COMMENT ON TABLE player_unlocked_perk IS 'Unlocked perk ids for a player (NEO-47); additive, idempotent per perk_id.';
