[Bug]: Migration 20260831120001 fails on partitioned "LiteLLM_SpendLogs" table (cannot create index concurrently)
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" concurrentlyExpected 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.
- Operator runs
prisma migrate deployagainst the PostgreSQL database. - Migration
20260831120000_add_litellm_call_id_spend_logsapplies successfully. - Migration
20260831120001_spend_logs_litellm_call_id_indexexecutes:CREATE INDEX CONCURRENTLY IF NOT EXISTS "LiteLLM_SpendLogs_litellm_call_id_idx" ON "LiteLLM_SpendLogs"("litellm_call_id"); - PostgreSQL rejects the statement with
ERROR: cannot create index on partitioned table "LiteLLM_SpendLogs" concurrently (SQLSTATE 0A000). - 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.
- Operator runs
prisma migrate deployagainst the PostgreSQL database. - Migration
20260831120000_add_litellm_call_id_spend_logsapplies successfully. - 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).
- 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:
prisma migrate deployFull 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:
CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogs_litellm_call_id_idx" ON "LiteLLM_SpendLogs"("litellm_call_id");and then running:
prisma migrate resolve --applied 20260831120001_spend_logs_litellm_call_id_indexallows 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
Source: BerriAI/litellm