diff --git a/litellm/proxy-extras/litellm_proxy_extras/migrations/20261115000000_customer_hierarchy_indexes/migration.sql b/litellm/proxy-extras/litellm_proxy_extras/migrations/20261115000000_customer_hierarchy_indexes/migration.sql new file mode 100644 index 00000000000..519990421b2 --- /dev/null +++ b/litellm/proxy-extras/litellm_proxy_extras/migrations/20261115000000_customer_hierarchy_indexes/migration.sql @@ -0,0 +1,7 @@ +SET LOCAL lock_timeout = '10s'; + +CREATE INDEX IF NOT EXISTS "LiteLLM_CustomerMemberTable_parent_team_ids_idx" ON "LiteLLM_CustomerMemberTable" USING GIN ("parent_team_ids"); +CREATE INDEX IF NOT EXISTS "LiteLLM_CustomerMemberTable_budget_id_idx" ON "LiteLLM_CustomerMemberTable"("budget_id"); +CREATE INDEX IF NOT EXISTS "LiteLLM_CustomerMemberTable_budget_override_id_idx" ON "LiteLLM_CustomerMemberTable"("budget_override_id"); +CREATE INDEX IF NOT EXISTS "LiteLLM_CustomerTeamTable_budget_id_idx" ON "LiteLLM_CustomerTeamTable"("budget_id"); +CREATE INDEX IF NOT EXISTS "LiteLLM_CustomerTeamTable_budget_override_id_idx" ON "LiteLLM_CustomerTeamTable"("budget_override_id"); diff --git a/litellm/proxy-extras/litellm_proxy_extras/schema.prisma b/litellm/proxy-extras/litellm_proxy_extras/schema.prisma index 3ca6db43106..9e1f47a5d1f 100644 --- a/litellm/proxy-extras/litellm_proxy_extras/schema.prisma +++ b/litellm/proxy-extras/litellm_proxy_extras/schema.prisma @@ -85,6 +85,8 @@ model LiteLLM_CustomerTeamTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) } @@ -107,6 +109,9 @@ model LiteLLM_CustomerMemberTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([parent_team_ids], type: Gin) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) } diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prisma index 3ca6db43106..9e1f47a5d1f 100644 --- a/litellm/proxy/schema.prisma +++ b/litellm/proxy/schema.prisma @@ -85,6 +85,8 @@ model LiteLLM_CustomerTeamTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) } @@ -107,6 +109,9 @@ model LiteLLM_CustomerMemberTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([parent_team_ids], type: Gin) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) } diff --git a/litellm/schema.prisma b/litellm/schema.prisma index 3ca6db43106..9e1f47a5d1f 100644 --- a/litellm/schema.prisma +++ b/litellm/schema.prisma @@ -85,6 +85,8 @@ model LiteLLM_CustomerTeamTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) } @@ -107,6 +109,9 @@ model LiteLLM_CustomerMemberTable { updated_at DateTime @default(now()) @updatedAt updated_by String @@index([parent_org_id]) + @@index([parent_team_ids], type: Gin) + @@index([budget_id]) + @@index([budget_override_id]) @@index([spend]) }