Skip to content

add missing indexes on VerificationToken table#20736

Merged
Sameerlite merged 1 commit intoBerriAI:mainfrom
CAFxX:verificationtoken-index
Feb 9, 2026
Merged

add missing indexes on VerificationToken table#20736
Sameerlite merged 1 commit intoBerriAI:mainfrom
CAFxX:verificationtoken-index

Conversation

@CAFxX
Copy link
Contributor

@CAFxX CAFxX commented Feb 9, 2026

⚠️ This changes the prisma.schema ⚠️

Relevant issues

Fixes #20730

Re-submit of #20040 as discussed with @Sameerlite on https://litellmossslack.slack.com/archives/C096ZG8HA9F/p1770603733130609

See #20040 for why this is needed.

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix
🚄 Infrastructure

Changes

Add missing indexes in VerificationToken table

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 9, 2026 8:05am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

This PR adds three database indexes to the LiteLLM_VerificationToken table to improve query performance for common access patterns:

  • user_id, team_id composite index - optimizes queries filtering by user and team combinations
  • team_id single-column index - optimizes queries filtering by team only
  • budget_reset_at, expires composite index - optimizes queries filtering tokens by budget reset time and expiration

The indexes are consistently applied across all three Prisma schema files (schema.prisma, litellm/proxy/schema.prisma, litellm-proxy-extras/litellm_proxy_extras/schema.prisma) with helpful SQL query comments documenting the specific query patterns being optimized. The migration file correctly creates these indexes using standard PostgreSQL syntax.

Confidence Score: 5/5

  • This PR is safe to merge - it only adds performance-improving indexes without modifying data or logic
  • The changes are purely additive (adding database indexes) with no code logic modifications. The indexes are properly defined in both Prisma schemas and the migration SQL, follow PostgreSQL best practices, and address legitimate performance concerns for common query patterns on the VerificationToken table.
  • No files require special attention

Important Files Changed

Filename Overview
litellm-proxy-extras/litellm_proxy_extras/migrations/20260209085821_add_verificationtoken_indexes/migration.sql Adds three database indexes for query optimization on LiteLLM_VerificationToken table
litellm-proxy-extras/litellm_proxy_extras/schema.prisma Adds three @@index directives with explanatory comments showing the queries they optimize
litellm/proxy/schema.prisma Adds three @@index directives with explanatory comments showing the queries they optimize
schema.prisma Adds three @@index directives with explanatory comments showing the queries they optimize

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant PR as Pull Request
    participant Prisma as Prisma Schema
    participant Migration as Migration File
    participant DB as PostgreSQL Database

    Dev->>Prisma: Add @@index directives to VerificationToken model
    Note over Prisma: Three schema files updated:<br/>- schema.prisma<br/>- litellm/proxy/schema.prisma<br/>- litellm-proxy-extras/schema.prisma
    
    Dev->>Migration: Create migration SQL file
    Note over Migration: Generates CREATE INDEX statements<br/>for three indexes
    
    PR->>Prisma: Schema changes committed
    PR->>Migration: Migration file committed
    
    Note over PR: PR Review & Merge
    
    Migration->>DB: Execute CREATE INDEX statements
    DB->>DB: Create user_id_team_id composite index
    DB->>DB: Create team_id single index
    DB->>DB: Create budget_reset_at_expires composite index
    
    Note over DB: Indexes applied to<br/>LiteLLM_VerificationToken table
    
    DB-->>Migration: Indexes created successfully
    
    Note over DB: Query performance improved for:<br/>- User+Team lookups<br/>- Team-only queries<br/>- Budget reset filtering
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Sameerlite Sameerlite merged commit a924a07 into BerriAI:main Feb 9, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing indexes in VerificationToken table

2 participants