ALTER TABLE agent_sessions ADD COLUMN grant_id TEXT; CREATE INDEX agent_sessions_grant ON agent_sessions(user_id, grant_id) WHERE ended_at IS NULL;