prisma/prisma
Prisma schema (PSL)
The user-facing schema file (schema.prisma) is written in PSL (Prisma Schema Language). It's a small declarative DSL with three top-level block types: datasource, generator, and model. PSL is parsed, validated, and formatted by @prisma/prisma-schema-wasm (compiled from Rust).
Block types
datasource db {
provider = "postgresql"
}
generator client {
provider = "prisma-client"
output = "../generated"
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}In Prisma 7, datasource URLs no longer live in the schema. Connection details come from prisma.config.ts instead. The datasource block stays, but it only declares the provider.
Models, fields, attributes
Models declare:
- Scalar fields with builtin types (
Int,String,Boolean,DateTime,Decimal,Bytes,Json, …) - Relation fields (
User?,Post[]) - Enum fields
- Composite type fields (Mongo only)
Attributes (@id, @unique, @default, @relation, @@index, @@map) modify field or model behavior. The full reference is in Prisma docs, not in this wiki — this page focuses on what's relevant for working on Prisma itself.
Multi-file schemas
@prisma/schema-files-loader handles split schemas — multiple .prisma files combined into one logical schema. This is the recommended pattern for large projects. The loader assembles the files, deduplicates, and hands a single textual representation to the parser.
Parsing pipeline
graph LR
Files[schema.prisma + extras] --> Loader[schema-files-loader]
Loader --> Text[Combined schema text]
Text --> Wasm[prisma-schema-wasm parser]
Wasm --> AST[Internal AST]
AST --> Validate[Validation]
Validate --> DMMF[DMMF JSON]
Validate --> Errors[Diagnostics]Errors come back from Wasm as structured objects; rendering happens in @prisma/internals.
Formatting
prisma format calls into the same Wasm artifact:
graph LR
File[schema.prisma] --> Read
Read --> Wasm[prisma-schema-wasm formatter]
Wasm --> Formatted[Formatted text]
Formatted --> Write[overwrite file]Implementation: packages/cli/src/Format.ts. It's a pure text-in/text-out call.
Validation
prisma validate is similarly thin:
graph LR
File[schema.prisma] --> Wasm[prisma-schema-wasm validator]
Wasm -->|ok| Exit0[exit 0]
Wasm -->|errors| Render[render diagnostics]
Render --> Exit1[exit 1]Implementation: packages/cli/src/Validate.ts.
Forced panics for testing
FORCE_PANIC_PRISMA_SCHEMA=1 npx prisma format
FORCE_PANIC_GET_DMMF=1 npx prisma validate
FORCE_PANIC_GET_CONFIG=1 npx prisma validateThese trigger panics in the Wasm parser to verify error-rendering paths in @prisma/internals.
See also
- Glossary: PSL
packages/cliFormat and Validate commands- DMMF for what the parser produces
@prisma/schema-files-loaderfor multi-file handling
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.