#41548·litellm

[Bug]: Migration 20260831120001 fails on partitioned "LiteLLM_SpendLogs" table (cannot create index concurrently)

Author: emerzonCreated Sep 17, 2026Updated Sep 29, 2026
Labelsproxy

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When running database migrations via prisma migrate deploy, migration 20260831120001_spend_logs_litellm_call_id_index fails if LiteLLM_SpendLogs is a PostgreSQL partitioned table.

PostgreSQL does not support CREATE INDEX CONCURRENTLY directly on partitioned tables, throwing:

Database error code: 0A000
Database error:
ERROR: cannot create index on partitioned table "LiteLLM_SpendLogs" concurrently

Expected behavior: Database migrations should succeed on deployments where LiteLLM_SpendLogs has been partitioned (e.g. for retention and high-volume spend logging).

User Flow

Before a (hypothetical) fix: an operator deploying LiteLLM on a PostgreSQL database with partitioned LiteLLM_SpendLogs runs migrations and encounters a hard deployment failure.

  1. Operator runs prisma migrate deploy against the PostgreSQL database.
  2. Migration 20260831120000_add_litellm_call_id_spend_logs applies successfully.
  3. Migration 20260831120001_spend_logs_litellm_call_id_index executes:
    sql
    CREATE INDEX CONCURRENTLY IF NOT EXISTS "LiteLLM_SpendLogs_litellm_call_id_idx" ON "LiteLLM_SpendLogs"("litellm_call_id");
  4. PostgreSQL rejects the statement with ERROR: cannot create index on partitioned table "LiteLLM_SpendLogs" concurrently (SQLSTATE 0A000).
  5. Prisma marks the migration as failed (P3018), blocking all subsequent migrations.

After a (hypothetical) fix: the migration succeeds on both partitioned and non-partitioned tables.

  1. Operator runs prisma migrate deploy against the PostgreSQL database.
  2. Migration 20260831120000_add_litellm_call_id_spend_logs applies successfully.
  3. The migration detects or handles partitioned tables (e.g., standard non-concurrent index creation on the parent table which automatically propagates to all child partitions, or indexing partitions individually before attaching).
  4. All migrations apply cleanly with status 0.

Proof the bug occurs

Migration file: litellm_proxy_extras/migrations/20260831120001_spend_logs_litellm_call_id_index/migration.sql (commit c0adca7c9420a0af46e8851a6f900c3111fbede9).

Execution:

bash
prisma migrate deploy

Full output:

Prisma schema loaded from schema.prisma
Datasource "client": PostgreSQL database "litellm", schema "public" at "localhost:5432"

177 migrations found in prisma/migrations

Applying migration `20260831120000_add_litellm_call_id_spend_logs`
Applying migration `20260831120001_spend_logs_litellm_call_id_index`
Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20260831120001_spend_logs_litellm_call_id_index

Database error code: 0A000

Database error:
ERROR: cannot create index on partitioned table "LiteLLM_SpendLogs" concurrently

DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E0A000), message: "cannot create index on partitioned table \"LiteLLM_SpendLogs\" concurrently", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("indexcmds.c"), line: Some(721), routine: Some("DefineIndex") }

Workaround used: Creating the index non-concurrently:

sql
CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogs_litellm_call_id_idx" ON "LiteLLM_SpendLogs"("litellm_call_id");

and then running:

bash
prisma migrate resolve --applied 20260831120001_spend_logs_litellm_call_id_index

allows prisma migrate deploy to resume and succeed.

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.75.0 / commit c0adca7c9420a0af46e8851a6f900c3111fbede9