Devii · Backend · 2026-05-11 · 8 min read
Prisma ORM: Schema-First Models, Migrations, And The Query Client
How Prisma maps models to SQL databases and what teams should know about migrations in production.
**Prisma** (`prisma.io`) uses a declarative **schema** file to generate a type-safe **client** for PostgreSQL, MySQL, SQLite, SQL Server, and other supported databases. `prisma migrate` tracks SQL migrations in version control.
`prisma generate` rebuilds the client after schema edits. Relations, enums, and indexes express in Prisma syntax then compile to dialect-specific SQL.
Production discipline: review generated SQL, avoid destructive changes without expand/contract patterns, and run migrations from CI/CD with backups. Prisma Accelerate and Pulse add connection pooling and change streams as optional services.
Prisma complements but does not replace raw SQL for every report query. Use `$queryRaw` when the query builder is awkward; keep parameters bound to prevent injection.