From 1af4e6bbe982b1aaa99bc063adfcc9c9432369ac Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 15 Apr 2026 01:28:11 -0400 Subject: [PATCH] fix(migration): add spend_logs api_key/end_user+startTime indexes --- .../migration.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 litellm-proxy-extras/litellm_proxy_extras/migrations/20260415000000_add_spend_logs_budget_indexes/migration.sql diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260415000000_add_spend_logs_budget_indexes/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260415000000_add_spend_logs_budget_indexes/migration.sql new file mode 100644 index 00000000000..83c22d46caf --- /dev/null +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260415000000_add_spend_logs_budget_indexes/migration.sql @@ -0,0 +1,6 @@ +-- CreateIndex: support fast per-key and per-end-user spend lookups +-- used by the cold-cache DB fallback in _PROXY_VirtualKeyModelMaxBudgetLimiter +CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogs_api_key_startTime_idx" ON "LiteLLM_SpendLogs"("api_key", "startTime"); + +-- CreateIndex +CREATE INDEX IF NOT EXISTS "LiteLLM_SpendLogs_end_user_startTime_idx" ON "LiteLLM_SpendLogs"("end_user", "startTime");