Skip to main content

Documentation 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.

The 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

Add prisma-next as a development dependency:
npm install -D prisma-next
No install needed for new projects — run init directly with your package manager’s one-off runner:
npx prisma-next init
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

CommandPurpose
prisma-next initScaffold a new Prisma Next project (config, schema, runtime).
prisma-next contract emitEmit contract.json and contract.d.ts from your schema.
prisma-next contract inferIntrospect a database and write an inferred PSL contract.
prisma-next db initBootstrap a database to match the current contract (additive only).
prisma-next db updateUpdate a database to match the current contract (including destructive ops).
prisma-next db schemaInspect the live database schema.
prisma-next db signWrite or update the contract marker on the database.
prisma-next db verifyVerify the database matches the emitted contract.
prisma-next migration planPlan a new migration from contract changes.
prisma-next migration showDisplay a migration package.
prisma-next migration statusShow the migration graph and applied status.
prisma-next migration applyApply planned migrations to the database.
prisma-next migration verifyVerify a migration package’s integrity.
prisma-next migration refManage named refs in migrations/refs.json.
Run prisma-next --help or prisma-next <command> --help for the full option surface of any command.

Global flags

All commands accept the following flags:
FlagShortDescription
--config <path>Path to prisma-next.config.ts. Defaults to ./prisma-next.config.ts in CWD.
--jsonEmit structured JSON output instead of human-readable text.
--quiet-qSuppress all output except errors.
--verbose-vPrint debug info and timings.
--trace-vvPrint deep internals and full stack traces.
--color / --no-colorForce or disable ANSI color output.

Exit codes

CodeMeaning
0Success.
1Runtime error (for example: marker missing, schema drift, migration failure).
2Usage or configuration error (for example: invalid flag combination, missing required config field).

Config discovery

The CLI looks for prisma-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).
# Use an explicit config path
prisma-next contract emit --config ./config/prisma-next.config.ts
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:
SubpathWhat it exports
@prisma-next/cli/config-typesdefineConfig and all config types
@prisma-next/cli/control-apicreateControlClient for programmatic control-plane operations
@prisma-next/cli/config-loaderloadConfig
@prisma-next/cli/commands/*Individual command factories (createContractEmitCommand, createDbInitCommand, …)
These subpaths are less stable than the facade packages (@prisma-next/postgres/config, @prisma-next/mongo/config). For application-level config, prefer the facade packages.

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.

Build docs developers (and LLMs) love