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.
This commit is contained in:
yuneng-jiang 2026-11-16 18:24:32 -08:00 • committed by GitHub
parent f33dcfd1dd
commit dc4c8a67b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 $$;