Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(proxy-extras): schema-qualify the _prisma_migrations logs lookup for non-public Prisma schemas

mateo-berri5192b2162c98
diff --git a/litellm-proxy-extras/litellm_proxy_extras/utils.py b/litellm-proxy-extras/litellm_proxy_extras/utils.py
index fb948afd200..97b6b1c667c 100644
--- a/litellm-proxy-extras/litellm_proxy_extras/utils.py
+++ b/litellm-proxy-extras/litellm_proxy_extras/utils.py
@@ -292,14 +292,22 @@ class ProxyExtrasDBManager:
return ""
cleaned_url = ProxyExtrasDBManager._strip_prisma_query_params(database_url)
+ ledger_table = psycopg.sql.SQL("{}.{}").format(
+ psycopg.sql.Identifier(
+ ProxyExtrasDBManager._prisma_schema_param(database_url) or "public"
+ ),
+ psycopg.sql.Identifier("_prisma_migrations"),
+ )
try:
with psycopg.connect(
cleaned_url, connect_timeout=10, autocommit=True
) as conn:
row = conn.execute(
- "SELECT logs FROM _prisma_migrations "
- "WHERE migration_name = %s AND finished_at IS NULL "
- "AND rolled_back_at IS NULL",
+ psycopg.sql.SQL(
+ "SELECT logs FROM {} "
+ "WHERE migration_name = %s AND finished_at IS NULL "
+ "AND rolled_back_at IS NULL"
+ ).format(ledger_table),
(migration_name,),
).fetchone()
except (psycopg.OperationalError, psycopg.DatabaseError):