Prisma 7 ORM
Rust-free TypeScript ORM with 90% smaller bundles and 3x faster queries.
Agent Workflow (MANDATORY)
Before ANY implementation, use TeamCreate to spawn 3 agents:
- fuse-ai-pilot:explore-codebase - Analyze existing schema and database patterns
- fuse-ai-pilot:research-expert - Verify latest Prisma 7 docs via Context7/Exa
- mcp__context7__query-docs - Check breaking changes and migration guide
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
When to Use
- Database access in Next.js 16 applications
- Type-safe queries with full TypeScript inference
- Schema-first database modeling and migrations
- Complex queries requiring TypedSQL
- Excluding sensitive fields with Omit API
Why Prisma 7
| Feature |
Benefit |
| Rust-free client |
90% smaller bundles (14MB → 1.6MB) |
| Query performance |
Up to 3x faster on large datasets |
| ESM-first |
Native ES modules, modern architecture |
| TypedSQL |
Type-safe raw SQL queries |
| Omit API |
Exclude sensitive fields globally |
| Driver adapters |
Direct database driver integration |
Breaking Changes from v6
Critical Migration Points
| Change |
v6 |
v7 |
| Provider |
prisma-client-js |
prisma-client |
| Output path |
Optional |
REQUIRED |
| Import |
@prisma/client |
./generated/prisma/client |
| Drivers |
Built-in |
Adapter required |
| Config |
Schema only |
prisma.config.ts |
Required Schema Changes
Provider must be prisma-client with explicit output path. No more generation to node_modules.
Driver Adapters Required
PostgreSQL requires @prisma/adapter-pg, MySQL requires @prisma/adapter-mariadb, SQLite requires @prisma/adapter-better-sqlite3.
SOLID Architecture
Module Structure
Database code organized in modules/cores/db/:
modules/cores/db/prisma.ts - Singleton PrismaClient
modules/cores/db/generated/ - Generated client
prisma/schema.prisma - Schema definition
prisma/migrations/ - Migration history
prisma.config.ts - Prisma configuration
File Organization
| File |
Purpose |
Max Lines |
prisma.ts |
Singleton client |
30 |
schema.prisma |
Models, relations |
100 per section |
seed.ts |
Database seeding |
50 |
Key Concepts
Singleton Pattern (Next.js)
Prevent multiple PrismaClient instances during hot-reload. Use globalThis to cache instance in development.
Output Path
Generated client goes to custom path, not node_modules. Import from generated folder.
Driver Adapters
Direct database driver integration for better performance and control. Configure connection pooling at driver level.
TypedSQL
Write raw SQL with full type safety. Results are typed based on query.
Omit API
Exclude fields globally or per-query. Perfect for passwords and sensitive data.
Reference Guide (130 files)
Core Setup
| Need |
Reference |
| Initial setup |
installation.md |
| PrismaClient singleton |
client.md |
| Client API methods |
client-api.md |
| Configuration |
prisma-config.md |
| CLI commands |
cli-reference.md |
| Editor setup |
editor-setup.md |
Schema & Modeling
| Need |
Reference |
| Schema design |
schema.md |
| Schema syntax |
schema-reference.md |
| Data modeling |
data-modeling.md |
| Field attributes |
field-attributes.md |
| Model attributes |
model-attributes.md |
| Enums |
enums.md |
| Default values |
default-values.md |
| Composite types |
composite-types.md |
| Scalar lists/arrays |
scalar-lists.md |
| Referential actions |
referential-actions.md |
Queries & Operations
| Need |
Reference |
| CRUD operations |
queries.md |
| Relations |
relations.md |
| Filtering |
filtering.md |
| Sorting |
sorting.md |
| Select vs Include |
select-include.md |
| Pagination (cursor) |
pagination-cursor.md |
| Pagination (offset) |
pagination-offset.md |
| Distinct |
distinct.md |
| Count & exists |
count-exists.md |
| Case sensitivity |
case-sensitivity.md |
| Aggregations |
aggregations.md |
| Transactions |
transactions.md |
Advanced Queries
| Need |
Reference |
| TypedSQL |
typedsql.md |
| Raw queries |
raw-queries.md |
| JSON fields |
json-fields.md |
| Full-text search |
full-text-search.md |
| Views |
views.md |
| Stored procedures |
stored-procedures.md |
| Triggers |
triggers.md |
| Constraints |
constraints.md |
| Advanced indexes |
indexes-advanced.md |
Migrations
| Need |
Reference |
| Migration workflow |
migrations.md |
| Seeding |
seeding.md |
| Baselining |
baselining.md |
| Shadow database |
shadow-database.md |
| Migration history |
migration-history.md |
| Squashing |
squashing.md |
| Hotfixing |
hotfixing.md |
| Down migrations |
down-migrations.md |
| Data migrations |
data-migrations.md |
| Zero-downtime |
zero-downtime.md |
Performance
| Need |
Reference |
| Optimization |
optimization.md |
| Query optimization |
query-optimization.md |
| N+1 problem |
n-plus-one.md |
| Batching |
batching.md |
| Lazy loading |
lazy-loading.md |
| Caching strategies |
caching-strategies.md |
| Connection limits |
connection-limits.md |
| Cold starts |
cold-starts.md |
| Bundle size |
bundle-size.md |
| Accelerate |
accelerate.md |
| Connection pooling |
connection-pooling.md |
Security
| Need |
Reference |
| Connection URLs |
connection-urls.md |
| Environment variables |
environment-variables.md |
| SSL/TLS |
ssl-tls.md |
| SQL injection |
sql-injection.md |
| Row-level security |
row-level-security.md |
| Encryption |
encryption.md |
| Audit logging |
audit-logging.md |
| GDPR compliance |
gdpr-compliance.md |
Databases
| Need |
Reference |
| PostgreSQL |
postgresql.md |
| MySQL |
mysql.md |
| SQLite |
sqlite.md |
| MongoDB (deprecated) |
mongodb.md |
| CockroachDB |
cockroachdb.md |
| PlanetScale |
planetscale.md |
| Supabase |
supabase.md |
| Neon |
neon.md |
| Turso |
turso.md |
Extensions & Integrations
| Need |
Reference |
| Extensions |
extensions.md |
| Driver adapters |
driver-adapters.md |
| Omit API |
omit-api.md |
| Middleware (deprecated) |
middleware.md |
| Soft delete |
soft-delete.md |
| Read replicas |
read-replicas.md |
| Multi-database |
multi-database.md |
| Multi-schema |
multi-schema.md |
Framework Integrations
| Need |
Reference |
| Next.js |
nextjs-integration.md |
| Astro |
astro.md |
| Nuxt |
nuxt.md |
| SvelteKit |
sveltekit.md |
| SolidStart |
solidstart.md |
| Remix |
remix.md |
| React Router |
react-router.md |
| Hono |
hono.md |
| Express |
express.md |
Auth Integrations
| Need |
Reference |
| Clerk |
clerk.md |
| Auth.js |
authjs.md |
| Better Auth |
betterauth.md |
| Permit.io |
permit-io.md |
Deployment
| Need |
Reference |
| Deployment guide |
deployment.md |
| Vercel |
vercel.md |
| Netlify |
netlify.md |
| Railway |
railway.md |
| Render |
render.md |
| Fly.io |
flyio.md |
| AWS Lambda |
aws-lambda.md |
| Cloudflare Workers |
cloudflare-workers.md |
| Docker |
docker.md |
| Heroku |
heroku.md |
| Deno Deploy |
deno-deploy.md |
Tooling
| Need |
Reference |
| VS Code |
vscode.md |
| GitHub Copilot |
github-copilot.md |
| Tabnine |
tabnine.md |
| SafeQL |
safeql.md |
| Prisma AI |
prisma-ai.md |
| MCP Server |
mcp-server.md |
| Turborepo |
turborepo.md |
| pnpm workspaces |
pnpm-workspaces.md |
Monitoring
| Need |
Reference |
| Error handling |
error-handling.md |
| Error codes |
error-codes.md |
| Logging |
logging.md |
| OpenTelemetry |
opentelemetry.md |
| DataDog |
datadog.md |
| Studio |
studio.md |
| Testing |
testing.md |
ORM Comparisons
| Need |
Reference |
| vs TypeORM |
vs-typeorm.md |
| vs Sequelize |
vs-sequelize.md |
| vs Drizzle |
vs-drizzle.md |
| vs Mongoose |
vs-mongoose.md |
| vs Kysely |
vs-kysely.md |
Migration Guides
| Need |
Reference |
| From TypeORM |
migrate-from-typeorm.md |
| From Sequelize |
migrate-from-sequelize.md |
| From Drizzle |
migrate-from-drizzle.md |
Best Practices
- Singleton in Next.js - Cache PrismaClient in globalThis
- Output path required - Never generate to node_modules
- Driver adapters - Use native drivers for better performance
- Omit sensitive fields - Configure global omit for passwords
- TypedSQL for complex - Use for queries Prisma can't express
- Index verification - Check query plans for N+1 issues
Forbidden Patterns
| Pattern |
Reason |
Alternative |
Import from @prisma/client |
v7 requires generated path |
Import from ./generated/prisma/client |
prisma-client-js provider |
Deprecated in v7 |
Use prisma-client |
| No output path |
Required in v7 |
Set output in generator |
| MongoDB |
Not supported in v7.0-7.3 |
Stay on Prisma 6 |
| url in datasource |
Deprecated |
Use prisma.config.ts |