LiteLLM upgrades and database migrations

A safe LiteLLM proxy upgrade reads every release note in between, pins an exact image tag, backs up PostgreSQL and times the migration against the spend log table. This page shows how to plan each step and what drives the effort.

On this page

How to upgrade LiteLLM without losing spend history or keys

A platform team running a self-hosted LiteLLM gateway needs to move it to a newer release without losing virtual keys, budgets or spend logs. The safe path is to read the release notes for every version between the current and target release, pin an exact image tag, and back up the PostgreSQL database before anything changes, because LiteLLM migrations only move forward. LiteLLM maintains support for the four most recent stable minor versions for both open source and Enterprise deployments, so a gateway that has fallen further behind is outside that window and should be moved first to a supported line. Confirm the current release on the LiteLLM GitHub releases page before you set the target, since the latest version changes often.

Start by writing down what the gateway holds that cannot be rebuilt: the LITELLM_MASTER_KEY, the LITELLM_SALT_KEY used to encrypt stored credentials, virtual key records, team and user budgets, and the LiteLLM_SpendLogs history that finance may depend on for chargeback. Keep the salt key unchanged across the upgrade, and confirm with the release notes that no setting in your configuration has been renamed or removed. Ask whether your version has a documented way to dry-run or stage the migration in a copy of the database, and whether a restore from your backup has been tested, not only taken. Those checks cost time up front, but they are the only way to know a rollback will work if the new release misbehaves.

The release notes also determine the sequence. A jump across several minor versions may introduce schema changes in each step, so the team should plan one target and one rehearsal in a non-production environment with a copy of production-sized data. Record the exact image tag, the migration duration observed in that rehearsal, and the proxy logs from startup. Those records turn the production window into a repeat of a known procedure rather than a first attempt. The large-table timing and migration timeout risks covered below apply directly to this rehearsal.

What changes between releases and what each change asks of you

This table maps the kinds of change you will meet between your current LiteLLM version and your target version, with the impact of each and the action it requires. Pull the actual rows from the release notes for every version in your range, because the specifics differ by release. Treat any row you cannot match to a release note as unverified until you confirm it.

ChangeImpactAction needed
Prisma migrations run at proxy startupBy default each pod runs prisma migrate deploy, and one pod holds a database lock while the others waitCheck the release notes for new migrations, then decide whether to run them once in a separate job or let pods run them
LITELLM_PRISMA_MIGRATE_DEPLOY_TIMEOUT (default 600 seconds)The proxy stops a migration after this timeout and retries it, so long migrations on large tables can loopRaise the timeout before upgrading if the release adds migrations that touch LiteLLM_SpendLogs
Image tag changesFloating tags such as main-latest can move under you, and tag naming can change between releasesPin an exact image tag, and confirm in the releases page that the tag you choose exists and matches the version you tested
Config keys added or renamedAn older version may not recognize a key added in the newer release, or may reject itCompare your config against the release notes for each version in range and remove or rename keys before rollout
Deprecated settings or endpointsBehavior you rely on may be removed or changed without a schema changeList every deprecation notice in the range, then test affected callers and admin automation in staging
Schema changes to spend and key tablesChanges to LiteLLM_SpendLogs or key tables can take locks for the duration of the migrationEstimate lock time on a restored copy of your production database before scheduling the window
Support window for your current lineLiteLLM supports the four most recent stable minor versions, so an older line may fall out of supportConfirm your current version is within the supported window and plan the move before it expires

What to inventory and back up before the first pod restarts

A migration can only be undone if the data and configuration it touches are known and recoverable. The items below cover the database, the configuration, the secrets, the Redis dependency and the staging rehearsal, and each one answers a question you need settled before any pod is restarted against a new image.

Verified PostgreSQL backup and restore

LiteLLM's upgrade guide says to back up the database because migrations only move forward. A backup that has never been restored is an assumption, not a recovery plan. Take a fresh backup immediately before the upgrade, restore it into a separate instance, and confirm that the proxy starts against it and that virtual keys, budgets and spend records are present. Record how long the restore took, since that is your real rollback time.

Upgrade guide

Inventory of config and callbacks

List every key in config.yaml, every custom callback and hook, and any environment variables that change proxy behavior. Newer releases may add or rename settings, and older releases may reject keys they do not know. Compare your file against the release notes for every version between your current and target release, and mark any custom code that imports internal modules, since those are the most likely to break between releases.

Master key and salt key in the secret manager

The LITELLM_MASTER_KEY, which must start with sk-, and LITELLM_SALT_KEY are needed to start the proxy and read encrypted data after an upgrade. Confirm both values are stored in your secret manager, not in a values file or shell history, and that the salt key is unchanged from the running deployment. Record who can read them and how a replacement would be issued if one were lost.

Redis version and role

LiteLLM's production guide requires Redis 7.0 or newer once more than one proxy instance runs, because Redis holds shared rate limits, router state and cache. Confirm the running Redis version, check whether it is reachable from every pod during the rollout, and decide whether cached router state should be flushed before or after the new pods come up. Ask your platform team for the maintenance window and failover behavior of that Redis deployment.

Staging copy of schema and spend log size

Build a staging database from a recent production backup so it has the same schema and a representative LiteLLM_SpendLogs table. Row count and table size drive migration time far more than the release itself. Run the target image against this copy, time each migration step, and compare the result against the lock estimates in your plan. A staging database with a small spend log will hide the lock problem you are trying to find.

How to run the upgrade sequence with checks and rollback points

This sequence moves a production LiteLLM proxy to a pinned target release with a verified backup, a rehearsed migration, and a smoke test of keys, budgets and routing, so each stage has a clear check and a known point to return to.

  1. Read every release note in between

    Before touching anything, list every LiteLLM version between your current release and the target, and read the release notes for each one. Look for schema changes, removed or renamed config keys, changed defaults and new environment variables. Record the items that affect your config, your callers and your database in a short upgrade record. The step is done when the upgrade record lists an action or a no-action decision for every intermediate version. Check the release history on the LiteLLM releases page and the upgrade guide.

  2. Pin the exact target image tag

    Choose one exact image tag for the target release and write it into your deployment manifest, Helm values or Terraform variables. Do not use a floating tag such as main-latest, because a pod restart could pull a different build than the one you tested. Commit the change so the tag is reviewable and reproducible. The step is done when the running configuration names the exact tag and a rendered manifest from the change matches it. Confirm the tag format for your release line before you pin it.

  3. Rehearse the upgrade on staging

    Deploy the pinned target tag to a staging environment that has a restored copy of production's PostgreSQL schema and a realistic volume of spend log rows. Run the migration, start the proxy, and watch startup logs for migration errors. Record how long the migration took and whether any step held a lock. The step is done when staging starts cleanly on the target tag and the timing is recorded. Staging rehearsal is the main source of evidence for the production change window, so treat a failed rehearsal as a stop point. Rollback point: staging can be rebuilt from the pre-rehearsal snapshot at no risk to production.

  4. Take and verify a fresh database backup

    Take a new PostgreSQL backup immediately before the production change, not a backup from the previous week. Confirm the backup completed and that you can restore it to a separate instance. Also save a copy of the current configuration, including the LITELLM_SALT_KEY value and the master key reference, stored outside the database. The step is done when a restore test to a scratch instance succeeds and the configuration copy is saved. Schema migrations only move forward, so this backup is the rollback point for data, and moving the image back to an older tag does not undo a schema change.

  5. Decide how migrations run

    Choose between the default behavior, where each proxy pod runs prisma migrate deploy at startup and one pod applies changes under a database lock while the others wait, and a single migration run before the proxy pods start. For a large spend log table, a single controlled migration run is easier to time, watch and stop than migrations hidden inside pod startup. Record the decision and the reason in the upgrade record. The step is done when the chosen method is written down and the pods are configured to match it. Check the setting for your deployment method in the upgrade guide.

  6. Raise the migration timeout for large tables

    The proxy stops prisma migrate deploy after LITELLM_PRISMA_MIGRATE_DEPLOY_TIMEOUT seconds, which defaults to 600, and then retries it. On a large LiteLLM_SpendLogs table a migration can run longer than that, so the retry loop can interrupt work that was still progressing. Raise the timeout in the configuration before the rollout, based on the staging timing you recorded. The step is done when the timeout value is set in the configuration and the staging timing is referenced in the upgrade record. Estimate lock duration from the staging rehearsal, not from general guidance, because index and rewrite times depend on your table size and hardware.

  7. Roll out and watch the migration

    Apply the change in the agreed window, watching migration logs and database lock activity while it runs. Confirm that the migration finished before the proxy pods begin serving traffic, or that the pods waiting on the lock started only after it released. Keep callers informed if writes will pause. The step is done when every pod reports a healthy state on the pinned tag and the migration history table shows the expected entries. Stop the rollout and escalate if a migration stalls past the staging timing. A rollback to the previous image is only safe for application code, not for the schema, so restore from the backup if the schema itself is at fault.

  8. Run health checks and a smoke test

    After the rollout, check liveness and readiness on every pod and confirm the proxy talks to PostgreSQL and Redis if you run more than one instance. Then run a smoke test that covers the features your teams depend on: create a test virtual key, confirm a budget and an RPM or TPM limit apply, send a request through a route to each provider you use, and confirm spend is recorded. Delete the test key afterward. The step is done when all checks pass and the results are saved with the upgrade record. If a check fails, compare it with the staging results and decide between a configuration fix and the rollback path described in the rollback procedure.

How long a migration on LiteLLM_SpendLogs will lock writes

The LiteLLM_SpendLogs table is the main risk in any LiteLLM upgrade because it grows with every request the gateway handles, and schema changes to it hold a lock for as long as the work runs. The LiteLLM upgrade guide estimates that a plain index build on this table takes about 4 to 8 seconds at 10 GB and about 1.5 to 3.5 hours at 10 TB. Table rewrites are far more expensive, ranging from about 1 minute to about 1 day, and the lock is held for the entire duration. During that window, writes to the table can queue or fail, so the gateway's spend tracking and logging are affected even if inference traffic keeps flowing.

These figures are the upgrade guide's estimates, not a promise about your database. Start by measuring your own table size with a query against PostgreSQL, then compare it with the migration notes in every release between your current version and your target. Confirm with the LiteLLM project which statements a given release runs against this table, since an index build and a rewrite carry very different lock costs. Then rehearse the upgrade on a staging copy restored from a recent backup of similar size, and time the migration end to end. Run the same hardware, PostgreSQL version and concurrent write load you expect in production, because lock waits depend on load as well as table size.

Use the rehearsal result to set the maintenance window and the proxy timeout. By default the proxy stops prisma migrate deploy after LITELLM_PRISMA_MIGRATE_DEPLOY_TIMEOUT seconds (600 by default) and retries it, so a long migration needs that value raised before the upgrade starts. Decide in advance whether a long run is acceptable, who approves a rollback if the lock outlasts the window, and what callers see while writes are blocked. Keep a verified backup of PostgreSQL taken immediately before the migration, because migrations only move forward.

How the migration, backup and rollout phases connect

The sequence starts with reading the release notes for every version between the current and target tags, then a staging rehearsal on a copy of production. Only after a PostgreSQL backup does the migration run, either inside each proxy pod at startup or once as a separate job. The migration step holds locks on the database, and the point of no return is reached once it completes, because migrations only move forward. Check health after rollout; if it fails, the rollback branch restores the backup and redeploys the prior pinned tag.

Phases from release notes to rollout, with the locking step and rollback branch marked.

What makes a LiteLLM upgrade take longer

How does spend log table size affect a LiteLLM migration?

A large LiteLLM_SpendLogs table is usually the biggest single driver of lock time, because some schema changes hold a lock on the table while they run. The supplied timing estimates for a plain index build on that table range from 4 to 8 seconds at 10 GB to 1.5 to 3.5 hours at 10 TB, and table rewrites range from about 1 minute to about 1 day. Before quoting, measure the table's total size and row count in your own PostgreSQL instance, check which migrations the target version contains, and confirm with the LiteLLM team which of them rewrite the table. Also confirm whether your proxy can tolerate write pauses for that window.

Does the number of versions between my current and target release matter?

Yes. The upgrade guide asks you to read the release notes for every version between your current release and your target, so each intermediate release adds review time, config changes and possibly migrations to test. A jump across several minor versions also means more chances of deprecated config keys or changed defaults. Count the releases in the LiteLLM releases page between the two versions, then note which ones change the database schema, the config format or the environment variables you use. Staging each hop, rather than jumping directly, is a common way to limit risk.

How do custom callbacks and config keys slow down an upgrade?

Custom callbacks, custom guardrails and hand-written config keys each need checking against the target release, because a renamed or removed key can stop the proxy from starting. Effort grows with the number of callbacks, the amount of Python code they contain and how many of them depend on internal behavior rather than documented hooks. A simple config with standard providers and keys usually moves with little change. Inventory every key in your config file and every callback, mark each as documented or internal, and test them in a staging environment that uses a copy of production data.

How do multiple proxy pods and Redis change the upgrade plan?

By default each proxy pod runs prisma migrate deploy at startup, with one pod doing the work under a database lock while the others wait. More pods mean more startup coordination to check, and the wait can extend the time the gateway is degraded. Redis matters because the production guide requires Redis 7.0 or newer once more than one proxy instance runs, for shared rate limits, router state and cache. Plan a rolling order for pods, confirm Redis compatibility with the target release, and measure how long a single pod takes to start on a copy of your database. A migrations job separated from the pods changes this step, so ask whether that pattern fits your deployment.

How does database hosting and restore time affect the backup step?

The upgrade guide says to back up the database before upgrading because migrations only move forward, so the restore time is the real measure of how much safety the backup gives you. A managed PostgreSQL service, a self-run server and a cluster with replicas each restore on different timelines and with different tooling. Measure how long a full restore of your production size takes into a separate environment, not just how long the backup takes. Also check whether your backup is consistent, whether it covers the spend history you need, and who has the permissions to restore it during a change window.

How do SSO and secret manager integrations add to upgrade effort?

Each integration adds a configuration surface that a new release can change. The admin UI supports SSO with Google, Microsoft Entra ID (Azure AD), Okta and generic OIDC providers, and Enterprise adds SCIM, JWT authentication and secret manager integrations for AWS, Azure, Google, HashiCorp Vault and CyberArk. Each of these needs its own settings, certificates or tokens to be retested after the upgrade. The effort rises with the number of identity providers, the number of secret stores and whether the settings are in environment variables or config files. Inventory each integration, record its settings, and include a login and secret read test in the post-upgrade checklist.

What should I measure before asking for an upgrade quote?

Gather the facts that set the scope, then the quote can follow from them. Record the current and target release, the number of releases between them, the spend log row count and table size, the number of proxy pods and whether Redis is in use, the database hosting model and a measured restore time, every custom callback and config key, and each SSO or secret manager integration. Also record the timeout your proxy uses for prisma migrate deploy, controlled by LITELLM_PRISMA_MIGRATE_DEPLOY_TIMEOUT, which defaults to 600 seconds. Share this inventory with any partner so the written scope reflects your environment rather than a generic estimate.

Can my own team handle an upgrade of this size?

Often yes for a small, standard deployment, but the drivers above determine whether it is a routine change or a planned project. A team that already runs PostgreSQL, Kubernetes and the identity provider can usually handle a simple config with a small spend table after reading the release notes. The effort increases when the spend table is large, custom code is involved, or the gateway must stay available during the migration window. The ownership question is who signs off on the backup restore test, who owns the rollback decision and who runs the post-upgrade checks. Name those owners before deciding whether to do it in-house or with a partner under a written scope.

How DeployOpen scopes and delivers a LiteLLM upgrade

DeployOpen plans LiteLLM upgrades and database migrations as fixed-scope work inside your own infrastructure. We read the release notes between your current and target versions, rehearse the migration on a copy of your database, and hand over a documented, tested runbook your team can repeat.

How we scope

  • Inventory the running version, image tags, database size and whether the proxy runs one or several pods.
  • Read every release note between the current and target versions and record breaking config changes.
  • Agree the written scope, deliverables and timeline before any change touches production.

How we build

  • Pin an exact image tag and rehearse the migration against a restored copy of your PostgreSQL database.
  • Measure migration timing on a copy that matches production spend log size, and raise the migration timeout as needed.
  • Confirm a verified backup exists before the change window, with a rollback path tested in staging.

How we hand over

  • Deliver a runbook with the exact steps, commands, checks and go or no-go criteria used in the rehearsal.
  • Document the measured migration timing, locking observations and any configuration changes made.
  • Walk your platform and database teams through the runbook so they can repeat the upgrade on their own.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing upgrades and support for later releases are available as a retainer.
  • Confirm with DeployOpen during scoping which support terms, response expectations and retest steps apply to your engagement.

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.