-- Indexes supporting OIDC single-logout queries.
--  * idx_sessions_oidc_reval backs the every-tick revalidation scan
--    (ListRevalidatableSessions): filter on OIDC sessions + ORDER BY last-checked.
--  * idx_sessions_user_id backs DeleteSessionsByUserID (sub-scoped logout) and
--    the session→user joins (SQLite does not auto-index foreign keys).
--  * idx_users_auth_provider_id backs the provider-scoped subqueries.
CREATE INDEX IF NOT EXISTS idx_sessions_oidc_reval ON sessions(oidc_last_revalidated_at) WHERE oidc_refresh_token != '';
CREATE INDEX IF NOT EXISTS idx_sessions_user_id ON sessions(user_id);
CREATE INDEX IF NOT EXISTS idx_users_auth_provider_id ON users(auth_provider_id);
