Skip to content

Add missing migration for LiteLLM_ToolTable policy changes - #22783

Merged
jquinter merged 1 commit into
mainfrom
fix/schema-migration-check
Mar 4, 2026
Merged

Add missing migration for LiteLLM_ToolTable policy changes#22783
jquinter merged 1 commit into
mainfrom
fix/schema-migration-check

Conversation

@jquinter

@jquinter jquinter commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • PR [Feat] Add Tool Policies for AI Gateway  #22732 changed the LiteLLM_ToolTable schema but didn't include a migration for it
  • Schema changes: renamed call_policyinput_policy, added output_policy, user_agent, last_used_at columns, updated indexes
  • This caused test_aaaasschema_migration_check to fail ("Schema changes detected - new migration required")

Migration details

ALTER TABLE "LiteLLM_ToolTable" RENAME COLUMN "call_policy" TO "input_policy";
ALTER TABLE "LiteLLM_ToolTable" ADD COLUMN "output_policy" TEXT NOT NULL DEFAULT 'untrusted';
ALTER TABLE "LiteLLM_ToolTable" ADD COLUMN "user_agent" TEXT;
ALTER TABLE "LiteLLM_ToolTable" ADD COLUMN "last_used_at" TIMESTAMP(3);
DROP INDEX IF EXISTS "LiteLLM_ToolTable_call_policy_idx";
CREATE INDEX "LiteLLM_ToolTable_input_policy_idx" ON "LiteLLM_ToolTable"("input_policy");
CREATE INDEX "LiteLLM_ToolTable_output_policy_idx" ON "LiteLLM_ToolTable"("output_policy");

Test plan

  • Migration SQL matches the schema diff between the old and new LiteLLM_ToolTable
  • All 3 schema files (root, proxy, proxy-extras) are already in sync for this model
  • test_aaaasschema_migration_check should pass in CI (requires PostgreSQL)

🤖 Generated with Claude Code

PR #22732 changed the ToolTable schema (renamed call_policy to
input_policy, added output_policy/user_agent/last_used_at columns,
updated indexes) but didn't include a migration for these changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Error Error Mar 4, 2026 2:28pm

Request Review

@greptile-apps

greptile-apps Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a missing database migration for LiteLLM_ToolTable schema changes that were introduced in PR #22732 but shipped without a corresponding migration file. The migration renames call_policy to input_policy, adds output_policy, user_agent, and last_used_at columns, and updates the associated indexes.

  • The migration SQL is correct and matches the current Prisma schema definitions across all three schema files (root, proxy, proxy-extras)
  • The column rename uses RENAME COLUMN which preserves existing data (no data loss)
  • The DROP INDEX IF EXISTS is defensive and safe for environments where the index may not exist
  • This should unblock test_aaaasschema_migration_check which was failing due to the schema/migration drift

Confidence Score: 5/5

  • This PR is safe to merge — it's a straightforward, correct SQL migration that brings the database in sync with the existing schema.
  • Single-file PR adding only a SQL migration file. The migration SQL correctly matches the schema diff between the old and new LiteLLM_ToolTable definitions across all three Prisma schema files. No application code changes, no risk of behavioral regressions.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm-proxy-extras/litellm_proxy_extras/migrations/20260303000000_update_tool_table_policies/migration.sql Adds migration for LiteLLM_ToolTable schema changes: renames call_policy to input_policy, adds output_policy/user_agent/last_used_at columns, and updates indexes. SQL is correct and matches all three Prisma schema files.

Entity Relationship Diagram

%%{init: {'theme': 'neutral'}}%%
erDiagram
    LiteLLM_ToolTable {
        String tool_id PK
        String tool_name UK
        String origin
        String input_policy "renamed from call_policy"
        String output_policy "new - default untrusted"
        Int call_count
        Json assignments
        String key_hash
        String team_id
        String key_alias
        String user_agent "new - nullable"
        DateTime last_used_at "new - nullable"
        DateTime created_at
        String created_by
        DateTime updated_at
        String updated_by
    }
Loading

Last reviewed commit: d8d3375

@jquinter
jquinter merged commit fac622b into main Mar 4, 2026
30 of 42 checks passed
@ishaan-berri
ishaan-berri deleted the fix/schema-migration-check branch March 26, 2026 22:29
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
Add missing migration for LiteLLM_ToolTable policy changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant