TheDocumentation 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 emits contracts, verifies and signs databases, and runs migrations from a type-safe contract. It is a devDependency — install it once per project and invoke it via your package manager’s script runner or npx/pnpm dlx.
Installation
Addprisma-next as a development dependency:
init directly with your package manager’s one-off runner:
prisma-next init prompts for your database (PostgreSQL or MongoDB) and schema location, scaffolds the config, schema, and runtime files, installs the target facade (for example @prisma-next/postgres) plus prisma-next, and emits your first contract.
Commands
| Command | Purpose |
|---|---|
prisma-next init | Scaffold a new Prisma Next project (config, schema, runtime). |
prisma-next contract emit | Emit contract.json and contract.d.ts from your schema. |
prisma-next contract infer | Introspect a database and write an inferred PSL contract. |
prisma-next db init | Bootstrap a database to match the current contract (additive only). |
prisma-next db update | Update a database to match the current contract (including destructive ops). |
prisma-next db schema | Inspect the live database schema. |
prisma-next db sign | Write or update the contract marker on the database. |
prisma-next db verify | Verify the database matches the emitted contract. |
prisma-next migration plan | Plan a new migration from contract changes. |
prisma-next migration show | Display a migration package. |
prisma-next migration status | Show the migration graph and applied status. |
prisma-next migration apply | Apply planned migrations to the database. |
prisma-next migration verify | Verify a migration package’s integrity. |
prisma-next migration ref | Manage named refs in migrations/refs.json. |
prisma-next --help or prisma-next <command> --help for the full option surface of any command.
Global flags
All commands accept the following flags:| Flag | Short | Description |
|---|---|---|
--config <path> | Path to prisma-next.config.ts. Defaults to ./prisma-next.config.ts in CWD. | |
--json | Emit structured JSON output instead of human-readable text. | |
--quiet | -q | Suppress all output except errors. |
--verbose | -v | Print debug info and timings. |
--trace | -vv | Print deep internals and full stack traces. |
--color / --no-color | Force or disable ANSI color output. |
Exit codes
| Code | Meaning |
|---|---|
0 | Success. |
1 | Runtime error (for example: marker missing, schema drift, migration failure). |
2 | Usage or configuration error (for example: invalid flag combination, missing required config field). |
Config discovery
The CLI looks forprisma-next.config.ts in the current working directory only — it does not walk up the directory tree. To use a config file at a different path, pass --config <path> (relative or absolute).
Config loading uses
c12 under the hood but is constrained to CWD. Running the CLI from a directory without a prisma-next.config.ts and without --config will produce a usage error (exit code 2).Programmatic use
prisma-next is a CLI distribution only — it has no library exports. Importing from the prisma-next package (root or any subpath) will fail at runtime.
Authors of build integrations, extension packs, and advanced config wiring should install @prisma-next/cli and import from its subpaths:
| Subpath | What it exports |
|---|---|
@prisma-next/cli/config-types | defineConfig and all config types |
@prisma-next/cli/control-api | createControlClient for programmatic control-plane operations |
@prisma-next/cli/config-loader | loadConfig |
@prisma-next/cli/commands/* | Individual command factories (createContractEmitCommand, createDbInitCommand, …) |
Command groups
contract emit
Emit
contract.json and contract.d.ts from your schema.contract infer
Infer a PSL contract from a live database for brownfield adoption.
db init
Bootstrap a new database to match the current contract (additive only).
db verify
Verify the database marker and schema match the emitted contract.
migration plan
Plan a new migration from contract changes — works fully offline.
migration apply
Apply planned migrations to a target database.