-- Migration: Add team_id index to refractor_card_state
-- Date: 2026-03-25
--
-- Adds a non-unique index on refractor_card_state.team_id to support the new
-- GET /api/v2/refractor/cards list endpoint, which filters by team as its
-- primary discriminator and is called on every /refractor status bot command.
--
-- The existing unique index is on (player_id, team_id) with player leading,
-- so team-only queries cannot use it efficiently.

BEGIN;

CREATE INDEX IF NOT EXISTS idx_refractor_card_state_team
    ON refractor_card_state (team_id);

COMMIT;

-- Rollback:
-- DROP INDEX IF EXISTS idx_refractor_card_state_team;
