From 46f88198ce9a549e6a18e80b72ed96a287999c74 Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 28 Oct 2026 00:59:18 +0000 Subject: [PATCH] fix(proxy): skip the migration replay when the ledger already records the files A failed migrate diff during the post-deploy sanity check (mark_all_applied=False) replayed every migration file onto an up-to-date database, which recreated the renamed LiteLLM_Engine tables and the dropped (prompt_id, version) unique index. The replay now only runs on the legacy no-ledger path, and a missing relation in the replay counts as a real failure instead of an idempotent one --- .../litellm_proxy_extras/utils.py | 10 +++++++ .../test_litellm_proxy_extras_utils.py | 27 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/litellm-proxy-extras/litellm_proxy_extras/utils.py b/litellm-proxy-extras/litellm_proxy_extras/utils.py index 3f825d2b026..aacbed6b8e1 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/utils.py +++ b/litellm-proxy-extras/litellm_proxy_extras/utils.py @@ -146,6 +146,7 @@ class _MigrateAttemptBudget: _SPEND_LOGS_ALTER_RE = re.compile(r'^ALTER\s+TABLE\s+"LiteLLM_SpendLogs"\s', re.IGNORECASE) _SPEND_LOGS_ARTIFACT_DROP_RE = re.compile(r'^DROP\s+TABLE\s+"LiteLLM_SpendLogs_[^"]*"', re.IGNORECASE) +_MISSING_RELATION: Final = re.compile(r'(?