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
This commit is contained in:
Tin Chi Lo 2026-07-27 12:29:19 -07:00
parent 2e12614a5b
commit a87754d7fc

View file

@ -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,