litellm/tests/test_litellm/proxy/db
Cursor Agent b0017fb46d
Phase 1: introduce SQLModel models alongside Prisma, with parity guard
Foundation for the multi-phase migration of the proxy persistence layer
from Prisma (prisma-client-py==0.11.0) to SQLModel/SQLAlchemy. This change
is non-functional at runtime: nothing imports the new package from the
existing proxy code paths.

Adds:

* litellm/proxy/db/sqlmodel/schema_parser.py
  Pure-Python parser for the subset of Prisma DSL used by schema.prisma.

* litellm/proxy/db/sqlmodel/_generate.py
  Code generator that emits SQLModel class definitions from a parsed
  schema. Produces Black-formatted output. Run manually after schema
  changes:

      uv run python -m litellm.proxy.db.sqlmodel._generate \
          --schema schema.prisma \
          --out litellm/proxy/db/sqlmodel/models.py

* litellm/proxy/db/sqlmodel/models.py
  SQLModel classes for all 64 Prisma models, hand-editable. Composite
  primary keys, @@unique, @@index (incl. map: '...' renames), @@map,
  String[] arrays, BigInt, Json/JSONB, @updatedAt, @default(uuid()/now()),
  and reserved Python attribute names (metadata -> metadata_) are all
  preserved structurally.

* tests/test_litellm/proxy/db/sqlmodel_orm/{test_schema_parser,test_parity}.py
  20 tests covering the parser unit cases, structural parity between
  every Prisma model and its SQLModel class (columns, nullability, type
  category, ARRAY-ness, primary keys, uniques, indexes), and a strict
  guard that the committed models.py is byte-identical to a fresh
  generator run.

* litellm/proxy/db/sqlmodel/README.md
  Phase 1 plan and the explicit out-of-scope items reserved for later
  phases (session abstraction, raw-SQL hotspot port, per-table call site
  migration, replacement of PrismaWrapper / RoutingPrismaWrapper /
  exception classifier, Alembic migrations, Prisma teardown).

Dependencies:

* Adds 'sqlmodel>=0.0.22,<1.0' to the extra_proxy optional group. This
  pulls in SQLAlchemy as a transitive dep. Existing Prisma deps are
  unchanged.

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-05-20 16:27:03 +00:00
..
db_transaction_queue [Fix] Preserve in-memory spend updates when Redis rpush fails 2026-04-22 14:10:40 -07:00
mcp_server build(VLLM-Passthrough-with-loadbalancing-support-(enables-using-model-list-for-VLLM-/classify-endpoint)): Closes #11205 2025-05-31 09:00:04 -07:00
sqlmodel_orm Phase 1: introduce SQLModel models alongside Prisma, with parity guard 2026-05-20 16:27:03 +00:00
test_check_migration.py build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
test_create_views.py [Fix] should_create_missing_views returns False for reltuples=0 (falsy zero bug) 2026-04-18 11:00:09 -07:00
test_db_spend_update_writer.py Merge PR #27221 into agent staging branch 2026-05-06 00:09:29 +00:00
test_db_url_settings.py feat: add componentized proxy deployment with gateway, backend, ui, and migrations (#27557) 2026-05-16 09:25:17 -07:00
test_exception_handler.py fix(proxy): restore broad is_database_connection_error; add is_database_transport_error for reconnect (#21796) 2026-02-21 12:04:00 -08:00
test_exception_handler_reconnect_retry.py fix(proxy): preserve original transport error if reconnect itself raises 2026-04-28 23:55:46 -07:00
test_prisma_client.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prisma_self_heal.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_dbReconnectNonBlocking_local 2026-04-29 13:57:35 -07:00
test_rds_iam_token_expiry.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_routing_prisma_wrapper.py feat: add read-replica routing for Prisma DB via DATABASE_URL_READ_REPLICA (#27493) 2026-05-08 21:05:50 -07:00
test_tool_registry_writer.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00