CREATE TABLE IF NOT EXISTS team_refresh_tokens (
    id BIGSERIAL PRIMARY KEY,
    team_member_id BIGINT NOT NULL REFERENCES team_members(id) ON DELETE CASCADE,
    token TEXT NOT NULL UNIQUE,
    expires_at TIMESTAMPTZ NOT NULL,
    revoked BOOLEAN NOT NULL DEFAULT FALSE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_team_refresh_tokens_team_member_id
    ON team_refresh_tokens (team_member_id);
