mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
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. |
||
|---|---|---|
| .. | ||
| dist | ||
| litellm_proxy_extras | ||
| tests | ||
| build_and_publish.md | ||
| LICENSE | ||
| migration_runbook.md | ||
| pyproject.toml | ||
| README.md | ||
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