From a87754d7fc6d0a42bd2c822de94e7c042a84c2fd Mon Sep 17 00:00:00 2001 From: Tin Chi Lo Date: Mon, 27 Jul 2026 12:29:19 -0700 Subject: [PATCH] fix(db_scripts): pin the tool spend backfill session to UTC The backfill compares the naive start_time column against a timestamptz cutover, and that coercion follows the session time zone, so a non-UTC session shifts the cutover boundary by the offset. Pinning the session makes the whole script timezone-independent. The date bucketing itself was already safe: to_char on a timestamp without time zone ignores the session time zone and the stored values are UTC --- db_scripts/backfill_daily_tool_spend.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db_scripts/backfill_daily_tool_spend.sql b/db_scripts/backfill_daily_tool_spend.sql index 358ebf1f23f..309b9dbe0ff 100644 --- a/db_scripts/backfill_daily_tool_spend.sql +++ b/db_scripts/backfill_daily_tool_spend.sql @@ -28,6 +28,8 @@ -- Usage: -- psql "$DATABASE_URL" -v cutover="'2026-07-25T00:00:00Z'" -f db_scripts/backfill_daily_tool_spend.sql +SET TIME ZONE 'UTC'; + INSERT INTO "LiteLLM_DailyToolSpend" (date, tool_name, spend, total_tokens, request_count, created_at, updated_at) SELECT to_char(ti.start_time, 'YYYY-MM-DD') AS date,