EveryDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/prisma/prisma-next/llms.txt
Use this file to discover all available pages before exploring further.
prisma-next CLI command reads a prisma-next.config.ts file to understand your database family, target, adapter, contract location, and optional connection details. The config is a TypeScript module that exports a default value produced by defineConfig. There are two ways to write it: the simplified facade approach (recommended for most projects) and the full explicit approach for advanced wiring.
Approaches
- Simplified (recommended)
- Full explicit
The This is the shortest path to a working config and is what
@prisma-next/postgres/config package exposes a defineConfig helper that pre-wires the SQL family, Postgres target, adapter, and driver. You only need to provide a contract path and, optionally, a database connection:prisma-next init scaffolds for Postgres projects.Required fields
The following fields must be present in any valid config (the simplified facade sets them for you):| Field | Type | Description |
|---|---|---|
family | descriptor | The database family (for example sql from @prisma-next/family-sql/control). |
target | descriptor | The specific database target (for example postgres from @prisma-next/target-postgres/control). |
adapter | descriptor | The query adapter for the target (for example postgresAdapter from @prisma-next/adapter-postgres/control). |
contract | provider | A contract provider created by typescriptContract() or prismaContract(). |
Optional fields
| Field | Type | Description |
|---|---|---|
driver | descriptor | Required for any command that connects to the database (db verify, db sign, db init, db update, db schema, contract infer, migration apply). Not needed for contract emit. |
extensionPacks | descriptor[] | Extension pack descriptors. Must include a descriptor for every extension pack referenced in the contract. |
db.connection | string | Default database URL. Can be overridden with --db <url> on any command. |
migrations.dir | string | Directory for migration packages. Defaults to migrations/. |
Commands that require a database connection will exit with error code
PN-CLI-4010 if driver is missing from the config, and PN-CLI-4005 if no connection URL is available from either db.connection or --db.Contract providers
Thecontract field takes a provider value rather than a plain path. Two providers ship out of the box:
typescriptContract — TypeScript-authored contracts
Use when your contract is authored in TypeScript and imported as a module:
prismaContract — PSL-authored contracts
Use when your contract is authored in Prisma Schema Language (.prisma files):
contract.d.ts is always co-located with contract.json and derived automatically from contract.output — you do not configure it separately.
Extension packs and wiring validation
When your contract declares extension packs, the CLI performs wiring validation before running anydb command that touches the database. It checks that:
contract.targetFamilymatchesconfig.family.familyIdcontract.targetmatchesconfig.target.targetId- Every extension pack listed in the contract is present in
config.extensionPacks(matched by descriptorid)
config.extensionPacks and re-run.
Commands that enforce wiring validation: db verify, db sign, db init, db update.
Commands that do not need a driver
prisma-next contract emit does not connect to the database, so driver and db.connection are not required:
Config validation
defineConfig validates and normalizes the config at load time using Arktype schemas. Validation failures produce actionable error messages. Normalization applies default values — for example, contract.output defaults to 'src/prisma/contract.json' when not specified.