litellm/litellm-proxy-extras
Yuneng Jiang 24e09f8a4e
fix(proxy): skip redundant Prisma work in the migration entrypoint
The migrations Job (`python litellm/proxy/prisma_migration.py`) kept spending
wall time on two Prisma CLI runs that cannot change anything:

`prisma generate` runs after every migration. Every shipped image already bakes
the client at build time from the same schema, so the refresh rewrites the
client with what it already holds, and on a non-root or read-only filesystem it
can only fail (it has been log-only since #37947 for that reason). It is also
the single slowest step of the Job, is unbounded, and logs nothing while it
runs, so a Job sitting inside it looks exactly like a Job still migrating. Skip
it when the installed client's copy of schema.prisma is byte-identical to the
one it would generate from; a source checkout with no generated client, or one
whose schema moved on, still generates as before.

The post-migration sanity check then diffs the database against schema.prisma
and applies the result. Right after a successful `prisma migrate deploy` that
diff is `-- This is an empty migration.`, and the code handed it to `prisma db
execute` anyway, paying a whole CLI invocation (plus a psycopg connection for
the partition check) to run nothing. Return early when the script has no
statements.

While there: `prisma migrate diff` writes into a file the code opens itself, so
a timed-out or failed diff leaves a possibly truncated script behind that the
existence check happily passed on to `prisma db execute`. Report whether the
diff ran to completion and never apply a partial one.

Measured on ghcr.io/berriai/litellm:main-latest against a fresh Postgres, one
container at 0.25 CPU / 2Gi: fresh database 131.6s -> 80.8s, already-migrated
database 118.7s -> 74.1s, same 78 tables either way. Real drift is still
corrected: dropping LiteLLM_BudgetTable.soft_budget and re-running the check
restores it.
2026-09-01 00:05:47 -07:00
..
dist adding build 2026-03-21 22:55:04 -07:00
litellm_proxy_extras fix(proxy): skip redundant Prisma work in the migration entrypoint 2026-09-01 00:05:47 -07:00
tests [Fix] v2 resolver: swallow non-connection DB errors; wrap resolve failures 2026-04-21 15:53:07 -07:00
build_and_publish.md build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
LICENSE install prisma migration files - connects litellm proxy to litellm's prisma migration files (#9637) 2025-03-29 15:27:09 -07:00
migration_runbook.md [Infra] Add freshness and destructive guards to migration workflow 2026-04-21 12:00:23 -07:00
pyproject.toml bump: litellm-enterprise 0.1.61 -> 0.1.62, litellm-proxy-extras 0.4.90 -> 0.4.91 2026-08-29 11:33:32 -07:00
README.md build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00

Additional files for the proxy. Reduces the size of the main litellm package.

Currently, only stores the migration.sql files for litellm-proxy.

To install, run:

uv add litellm-proxy-extras

OR

uv tool install 'litellm[proxy]' # installs litellm-proxy-extras and other proxy dependencies

To use the migrations, run:

litellm --use_prisma_migrate