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.
This commit is contained in:
Etienne Chabert 2026-09-18 15:40:50 +02:00
parent 923f865fd5
commit 3df010cd68
No known key found for this signature in database

View file

@ -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");