From dc4c8a67b57e573fdcedfc4c1c077c536dbb440c Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Mon, 16 Nov 2026 18:24:32 -0800 Subject: [PATCH] fix(migrations): bring customer hierarchy tables in line with schema.prisma (#52175) The customer daily usage migration gave LiteLLM_DailyCustomerMemberSpend.updated_at a DEFAULT CURRENT_TIMESTAMP that schema.prisma never declared, and the customer hierarchy cleanup renamed the default budget template foreign key to a 65 character name that Postgres cut to 63 characters, which is not the name Prisma derives. prisma migrate diff reported both, so test_schema_migration_in_sync failed on every main integration run. The new migration drops the updated_at default, matching every other daily spend table. The only writer, the daily spend bulk upsert, always sets updated_at itself. It also renames the truncated foreign key to the name Prisma expects, guarded so databases that never got the truncated name are left alone. --- .../migration.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 litellm/proxy-extras/litellm_proxy_extras/migrations/20261116000000_customer_hierarchy_prisma_drift/migration.sql diff --git a/litellm/proxy-extras/litellm_proxy_extras/migrations/20261116000000_customer_hierarchy_prisma_drift/migration.sql b/litellm/proxy-extras/litellm_proxy_extras/migrations/20261116000000_customer_hierarchy_prisma_drift/migration.sql new file mode 100644 index 00000000000..f353e8080ab --- /dev/null +++ b/litellm/proxy-extras/litellm_proxy_extras/migrations/20261116000000_customer_hierarchy_prisma_drift/migration.sql @@ -0,0 +1,14 @@ +SET LOCAL lock_timeout = '10s'; + +ALTER TABLE "LiteLLM_DailyCustomerMemberSpend" ALTER COLUMN "updated_at" DROP DEFAULT; + +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 FROM pg_constraint + WHERE conname = 'LiteLLM_CustomerOrganizationTable_default_budget_template_id_fk' + AND conrelid = '"LiteLLM_CustomerOrganizationTable"'::regclass + ) THEN + ALTER TABLE "LiteLLM_CustomerOrganizationTable" RENAME CONSTRAINT "LiteLLM_CustomerOrganizationTable_default_budget_template_id_fk" TO "LiteLLM_CustomerOrganizationTable_default_budget_template__fkey"; + END IF; +END $$;