Fixing LiteLLM Prisma migration errors after an upgrade or rollback

A LiteLLM proxy that crash-loops after a version change is usually a schema history mismatch. This page explains how to diagnose it, fix it safely and avoid data loss.

On this page

Why LiteLLM pods crash-loop after an upgrade or rollback

When LiteLLM pods restart in a loop after a new or rolled-back image, the usual cause is a mismatch between the Prisma migration history in PostgreSQL and the image running now. LiteLLM exits nonzero when database setup fails rather than serving requests against an older schema, so the crash is the safety check working. The logs will point at database setup because that is where the proxy stopped. Read the first migration error in the pod log before changing anything else, since later errors are usually consequences of it.

The supported path is to plan changes along a release line. LiteLLM maintains support for the four most recent stable minor versions for both open source and Enterprise deployments, according to its enterprise documentation. Confirm which minor line your production gateway is on, check that your target image is still inside that window, and read the release notes for every minor version between the two. Staying on a supported line gives you a known migration path, and it keeps a rollback target available if the new release misbehaves.

Before you investigate further, record three facts: the image tag currently deployed, the tag you ran before, and whether any migration has already been applied by the newer image. The _prisma_migrations table in PostgreSQL holds that history, so it is the first thing to inspect. Confirm with your own database owner whether a recent backup exists that you can restore to, because the fixes described below change migration records and some of them can affect data.

Which symptoms point to which migration cause

This table matches what you see on a crash-looping LiteLLM pod to the most likely migration cause, the first check to run and the action that follows. Read it from the symptom column, then confirm the cause in the _prisma_migrations table before changing anything. The main takeaway is that deleting a migration entry is a documented fix only for the rollback pattern, and the other rows need a different first step.

SymptomLikely causeFirst checkAction needed
Proxy exits nonzero during database setupPrisma migration step failed, so the proxy stopped instead of serving an older schemaRead the startup log for the migration error and the exit codeFix the reported database error, then restart; confirm the database is reachable from the pod
Relation does not exist after a rollbackOlder image found newer migrations already recorded as applied in _prisma_migrationsCompare the migration names in _prisma_migrations with the migrations shipped in the image you runDelete the failed migration entry as documented, then restart so it is re-applied
A migration is marked failedAn earlier migration did not finish, and its record was left in a failed stateQuery _prisma_migrations for rows with a failed status and note their namesDelete only the failed entry for that migration, restart, and confirm the proxy starts cleanly
Schema drift after a manual changeSomeone edited tables or columns outside the Prisma migrations, so the schema no longer matches the migration historyCompare the live schema with the migration history and list any changes made by handTake a database backup first, then decide with your DBA whether to reconcile the schema; do not delete entries blindly
Pod starts on a new image with an older databaseThe new image expects migrations the database has not received, and startup did not complete themCheck the image tag on the running pod and the migration state in the databaseLet the matching release run its migrations once, or follow your upgrade runbook; avoid manual schema changes

Choosing a fix for a failed or rolled-back migration

A rollback leaves the database ahead of the code. The older image starts, but _prisma_migrations still lists migrations from the newer release as applied, so the older schema and the migration history disagree. A relation does not exist error after a rollback is the typical sign: the newer release wrote a table or column the older release does not expect to find in the same state, or the history claims a change that the older code path cannot use. The documented fix is to delete the failed migration entry and restart so it is re-applied. Confirm which migration names the older image expects before you delete anything, because removing the wrong row changes what the next startup attempts to run.

  • Diagnose first: compare the migration names in _prisma_migrations with the migrations shipped in the image you rolled back to.
  • Back up before any change: take a PostgreSQL backup that you have verified can be restored, and record the current _prisma_migrations contents.
  • Delete only the failed entry: remove the row for the migration that the older release cannot complete, not the whole table.
  • Restart and watch startup: confirm the proxy starts cleanly and that the migration logs show the expected re-application.
  • Keep the master salt key unchanged: rollback fixes should not change LITELLM_SALT_KEY, or stored credentials may become unreadable.

Before you start, confirm with your platform owner which image tag you are returning to and whether that release's schema is a subset of the current one.

What to back up and confirm before touching migration records

Editing _prisma_migrations changes the only record of what the database has applied, so it should never be the first step. The cards below cover the artifacts and settings that let you return to a known state if a fix goes wrong. Work through them in order before you delete or re-apply any migration entry.

PostgreSQL backup and restore test

Take a full backup of the LiteLLM database before any change, then restore it into a separate instance and confirm the proxy starts against it. A backup that has never been restored is a hope, not a rollback path. Check that the restore includes the _prisma_migrations table and the spend and key tables. Confirm the backup method and point-in-time recovery options against the PostgreSQL continuous archiving documentation, since a logical dump alone may not give you a recent enough restore point for a busy gateway.

Continuous archiving docs

Copy of the _prisma_migrations table

Export the _prisma_migrations table to a file before you change any row. It records which migrations Prisma considers applied, their checksums and whether any failed, so it is the exact state you need to reason about a crash-loop. Keep the export alongside the database backup so you can compare the before and after states when a relation does not exist error appears.

Image tag and configuration in use

Record the exact LiteLLM image tag the pods run now, the tag you are moving to or back to, and the mounted configuration file or environment values. The migration history matches a specific release, so you need to know which version wrote the rows you are looking at. Pin tags rather than relying on a floating label, and note any config keys the older release may not understand.

LITELLM_SALT_KEY kept unchanged

Confirm that LITELLM_SALT_KEY has the same value in the running deployment, the backup context and the version you plan to restore. The salt is used to encrypt stored credentials such as provider keys, so a changed value can leave the restored database unable to read them. Store it in your secret manager with its history, and do not regenerate it during a migration repair.

Staging copy of the database

Restore the backup into a staging environment that runs the same image tag as production, and try the fix there first. Staging shows whether deleting the failed entry and restarting lets the proxy apply the remaining migrations cleanly. It also reveals how long the migration takes on your data volume, which matters if the production table is large. Use a copy with realistic row counts rather than an empty schema.

Recovering a crash-looping LiteLLM proxy safely

This sequence stops the restart loop without touching data, records the evidence, and restores a healthy proxy through the documented fix or a supported image, with a rollback point at each step.

  1. Stop the restart loop without changing data

    The platform owner scales the proxy deployment down or pauses the rollout so pods stop retrying startup, and confirms that no database migration, schema push or manual SQL is running. Do not drop, reset or edit tables at this point. In Kubernetes, check that the replica count is zero or that the Deployment is paused, then confirm with a pod list that no new containers are starting. The step is done when the restart count stops rising and the database is left exactly as the failed startup left it. Rollback point: scaling back up restores the previous state, since nothing has been changed yet.

  2. Capture the startup error and migration state

    The on-call engineer saves the logs from the last failed container, including the exit code, and records the running image tag and the previous image tag from the release history. Then they query the migration table read-only to list the rows in _prisma_migrations, noting which migrations are marked as applied, which have a failure marker and which are missing. Store the output in the change ticket. The step is done when the error text, exit code, image tags and migration table snapshot are all attached to the ticket and the team agrees on which migration failed. Rollback point: this step is read-only, so there is nothing to reverse.

  3. Confirm a verified backup of PostgreSQL

    The database owner confirms that a backup of the LiteLLM database was taken before the upgrade or rollback and that it can be restored. Ask for the backup timestamp, the method used and the result of a test restore to a separate instance. If no usable backup exists, take one now with the database running in its current state, and check that the backup completes without errors. The step is done when the team can name the backup and its restore test result. Rollback point: the backup is the rollback point for every later step, so no destructive action starts until it is confirmed.

  4. Choose between re-applying or moving to a supported image

    The platform lead compares the release the database was last migrated for with the running image. If the failure is a relation does not exist error after a rollback, and _prisma_migrations still lists newer migrations as applied, the documented fix applies. If the error points to a schema the older image cannot match, or the failing migration is unclear, the safer path is to move the proxy to a supported image that matches the database state. Confirm the supported release lines against the LiteLLM release notes and the enterprise support policy before choosing. The step is done when the decision and its reason are written down. Rollback point: the decision is recorded so that the other option remains available if the first one fails.

  5. Delete only the failed migration entry

    If the documented fix applies, the database owner removes only the single row for the failed migration from _prisma_migrations, identified by its name from the captured log. Do not delete other rows, do not run prisma db push and do not edit application tables. Confirm the row count changed by exactly one and save the before and after query output. The step is done when the failed migration no longer appears in the table and the other history rows are unchanged. Rollback point: restore the backup from the earlier step if the table or data looks wrong, since the deleted row is the only change made.

  6. Restart and verify health and a test request

    The platform team starts one proxy replica, watches the logs until startup completes without a nonzero exit, and confirms that the migration history now shows the migration as applied. Then they check the proxy health endpoint and send one test request with a test virtual key to a model that the key is allowed to use, and confirm a normal response in the proxy logs. Scale back up only after this succeeds. The step is done when the single replica stays running through startup, the health check passes and the test request returns a valid response. Rollback point: if the replica fails again, scale it down and return to the backup or the supported image path instead of retrying the deletion.

  7. Record the incident and the decision

    The team writes a short record that lists the image tags involved, the error text, the migration table state before and after, the backup used, the option chosen and the test results. They also note the controls that would have caught the problem earlier, such as a pre-change backup check or a restore test. Store the record with the change ticket and link it to the upgrade or rollback runbook. The step is done when the record is reviewed by the database owner and the platform lead, and the runbook is updated with any missing check.

When prisma db push can cause data loss

The LiteLLM troubleshooting guide warns that prisma db push can cause data loss when the Prisma schema removes columns or tables, so treat it as a last resort on a production database rather than a routine recovery step. The two commands work from different sources of truth. prisma migrate deploy applies only the migration files that have been recorded and not yet applied, in order, and it records each one in the _prisma_migrations table. prisma db push ignores that history and instead changes the database until its structure matches the current Prisma schema directly. If the schema no longer contains a column or table that still holds data, the push can drop it, and no migration record exists that would let you trace or reverse the change.

Before anyone runs prisma db push against a database that holds spend logs, keys or budgets, take a PostgreSQL backup and restore it to a separate copy. Run the push against that copy, then review the generated statements and row counts for every table involved. Look specifically for DROP statements and for column type changes that could truncate values. Confirm with LiteLLM support, using the exact image tag and schema version you run, that the push is the correct fix for your error and that it will not remove objects your running version still reads. Record the approval, the backup identifier and the reviewed statements in your change ticket.

Most rollback errors are better handled through the documented path of removing the failed migration entry and restarting, because that keeps the change inside the migration history your team can audit. Reserve prisma db push for cases where support has confirmed the schema state and you have a tested restore point. If you do use it, run the proxy against the restored copy first, confirm that pods start and that keys, teams and spend data read back correctly, and only then schedule the same change on the production database during a window your operators have agreed.

How the proxy, Prisma and PostgreSQL interact at startup

The diagram starts when a LiteLLM pod boots and hands control to prisma migrate deploy, which reads the _prisma_migrations table in PostgreSQL and applies any pending migrations. The proxy serves traffic only if that step succeeds; otherwise the process exits nonzero and the pod restarts. The rollback branch shows how a database that already lists newer migrations leads to a relation does not exist error, and the documented fix is to delete the failed migration entry and restart so it is re-applied. Check the migration table before deleting anything.

Startup path for the proxy, Prisma migrations and PostgreSQL, including the rollback failure loop.

Questions teams ask before fixing a LiteLLM migration failure

How long does it take to fix a LiteLLM Prisma migration error?

The time depends on how many migration records are out of step, whether the failure is a simple stale entry or a schema mismatch, and how large the database is. A single failed entry that is cleared and re-applied on restart is usually a short task. A rollback that left several newer migrations recorded as applied takes longer, because each one needs checking against the schema the running version expects. The biggest unknowns are the state of the _prisma_migrations table and whether a clean backup exists. Ask for a written scope that names the diagnosis steps, the environments touched, and the verification you will receive before the fix is called done.

Can our own team fix a LiteLLM migration failure without outside help?

Often yes, if the team has PostgreSQL administration skills and access to the LiteLLM logs, the running image tag, and the database. The documented path is to read the startup error, inspect _prisma_migrations, delete the failed migration entry where the troubleshooting guide says to, and restart so the migration is re-applied. The risk comes from guessing. Deleting the wrong row, running prisma db push on a schema that drops objects, or changing the image tag without a backup can turn a startup failure into lost data. Teams without a database owner on call should treat the fix as a planned change, not an emergency patch.

What does the work need from our team before it starts?

Plan for four things: read access to the crash logs and the running image tag, administrative access to the PostgreSQL database that LiteLLM uses, a current backup that can be restored, and a staging environment running the same LiteLLM version and schema history as production. Staging matters because the fix should be rehearsed on a copy before it touches the system that serves callers. Also confirm who approves changes to the database and who can roll back. The PostgreSQL upgrading documentation and the LiteLLM troubleshooting guide are the references to share with your database owner before the first session.

Is deleting a failed migration entry risky for our data?

Deleting a failed entry in _prisma_migrations changes only the migration history, not the spend logs, keys, or budgets, but the outcome depends on what the migration did before it failed. A partially applied migration may have created or altered tables, so re-running it can fail again or conflict with existing objects. Take a PostgreSQL backup before any change to that table, record the current rows, and confirm which objects the failed migration touched. Do not use prisma db push as a shortcut, because the LiteLLM troubleshooting guide warns it can cause data loss when the schema removes columns or tables.

When does prisma db push risk data loss in LiteLLM?

The risk is highest when the Prisma schema you push removes columns or tables that hold data your organization needs, such as spend history or key records. The LiteLLM troubleshooting guide names this risk directly, so treat prisma db push as an operation that needs a backup, a reviewed diff, and a rehearsal in staging. In most recovery cases the safer route is the documented path of clearing the failed migration entry and letting LiteLLM apply its own migrations on startup. Ask your engineers to show the schema changes that a push would make before anyone runs it against production.

Should we involve LiteLLM or a partner, and when?

Involve the vendor or a partner when the error repeats after a documented fix, when the logs point to a schema state the troubleshooting guide does not cover, or when the database holds spend data your finance or audit teams depend on. LiteLLM Enterprise includes a dedicated support channel with the engineering team, and its enterprise documentation describes optional 24/7 SLAs, so check whether your license includes them before an incident. A partner such as DeployOpen can plan the diagnosis, rehearse the fix in staging, and document the evidence. Ask any partner for a fixed-scope written agreement before work starts.

Does LiteLLM support the PostgreSQL version we run?

Confirm this against the LiteLLM production guide and the PostgreSQL versioning policy before any change. PostgreSQL 14 is supported until November 12, 2026, and PostgreSQL 13 and earlier are no longer supported, so a database that is out of support adds risk to any migration. Ask your database owner which major version runs in production, and plan any major upgrade as a separate change with its own backup and rollback steps. Migration failures and database upgrades can look alike in the logs, so confirm the database version before diagnosing the LiteLLM schema.

Staying on a supported LiteLLM release line

Staying on a supported release line is the first control against migration trouble, because a Prisma error is far easier to fix when the gap between your running version and the target is small. LiteLLM states that it maintains support for the four most recent stable minor versions, for both open source and Enterprise deployments. The GitHub releases page lists v1.105.1, published October 14, 2026, as a current release. Before you plan any change, check the LiteLLM releases page for the newest stable line, confirm which minor versions still receive support, and record the version your pods run today. A deployment that has fallen out of the supported window will have a harder time getting a clean path forward.

A rollback that crosses many migrations is harder than a forward fix. Each release can add tables, columns and rows to _prisma_migrations. When you roll the image back to an older tag, the database still reflects the newer schema, so the older proxy may find tables and migration records it does not expect. The more releases you skip in either direction, the more migration entries you have to reason about, and the more likely you are to need manual cleanup. Before you touch the migration table, read the release notes for every version between the one you ran and the one you intend to run, and confirm which migrations each release applied.

LiteLLM's production guide names PostgreSQL as the primary supported database, so the migration history you are repairing lives there. Check which PostgreSQL major version your database runs against the supported windows in the PostgreSQL versioning policy, since an end-of-life database adds a second upgrade to an already complicated change. Confirm your database's support end date with your platform team, and take a verified backup before any rollback so that you can restore the exact state you started from.

How DeployOpen works on this

DeployOpen approaches Prisma migration failures in a self-hosted LiteLLM gateway by first reading the migration history and the deployed image versions, then changing the database in a controlled, documented way. Each engagement is fixed-scope, with the scope, deliverables and timeline agreed in writing before any work starts.

How we scope

  • Collect the running image tags, the previous and target releases, and the startup logs from the crash-looping pods.
  • Review the _prisma_migrations table and confirm which migrations are recorded as applied for the schema in use.
  • Agree in writing whether the work covers diagnosis only, a guided repair, or repair plus a documented recovery runbook.

How we build

  • Take and verify a PostgreSQL backup before any change to the migration history, so every step can be reversed.
  • Remove only the failed or orphaned migration entry the release notes and logs identify, then restart so the proxy re-applies it.
  • Test the fix on a copy of the database and document any step that would run prisma db push against a schema that drops data.

How we hand over

  • Deliver a written record of the root cause, the commands run, the backup location and the verification results.
  • Provide a runbook covering how to pin image tags, check migration state, and roll back without orphaning schema changes.
  • Walk the platform team through the procedure so they can repeat it for future upgrades and rollbacks.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, agreed separately from the initial scope.
  • Retainers can cover review of each planned LiteLLM release and its migration steps before the platform team applies it.
  • Ask the team to confirm the support hours, response expectations and escalation path in the written agreement before work starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.