From 3df010cd68c2b3ea32c6611b8477939aa7597798 Mon Sep 17 00:00:00 2001 From: Etienne Chabert Date: Fri, 18 Sep 2026 15:40:50 +0200 Subject: [PATCH] docs(migrations): explain why the spend index swap is not CONCURRENTLY Postgres rejects CREATE INDEX CONCURRENTLY on a partitioned table even with IF NOT EXISTS and the index already present (verified on 18.4), so a concurrent build would fail 20260918120000 on every partitioned install, including stable upgrades where 20260823000000 already built the index. Record that, and the pre-create escape hatch, next to the statement. --- .../migration.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260918120000_spend_logs_api_key_index_cover_spend/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260918120000_spend_logs_api_key_index_cover_spend/migration.sql index ef66911bed8..1e35f7dafd7 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260918120000_spend_logs_api_key_index_cover_spend/migration.sql +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260918120000_spend_logs_api_key_index_cover_spend/migration.sql @@ -6,6 +6,13 @@ -- -- No-op where 20260823000000 already built the covering index. The new index is -- built before the old one is dropped, so reads keep an index throughout. +-- +-- Not CONCURRENTLY on purpose: Postgres rejects CREATE INDEX CONCURRENTLY on a +-- partitioned LiteLLM_SpendLogs (db_scripts/partition_spend_logs.sql) even with +-- IF NOT EXISTS and the index already present, so it would fail this migration +-- on every partitioned install. The blocking build only runs where the earlier +-- (api_key, startTime) version of 20260823000000 was applied. To avoid it, +-- pre-create the index CONCURRENTLY under the same name; the build then no-ops. -- CreateIndex CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogs_api_key_startTime_spend_idx" ON "LiteLLM_SpendLogs"("api_key", "startTime", "spend");