Skip to main content
prisma-next db schema connects to a live database, queries its catalog, and renders the discovered schema as a human-readable tree or a machine-consumable JSON envelope. The command is entirely read-only — it never writes files, modifies schema, or touches the contract marker. This is useful for spot-checking what a database actually contains, debugging schema drift, or confirming the result of a migration before signing. The output reflects native database types (for example int4, text, timestamptz) rather than mapped codec IDs, giving you an accurate view of the actual database state.

Options

string
Database connection string. Optional when db.connection is set in your config file.
string
Path to prisma-next.config.ts. Defaults to ./prisma-next.config.ts in the current working directory.
string
Output a JSON result envelope to stdout instead of the TTY tree.
boolean
Quiet mode. Suppresses all output except errors.
boolean
Verbose mode. Prints debug information and timing data.
boolean
Trace mode. Prints deep internals and full stack traces.
boolean
Force color output. Use --no-color to disable color output entirely.

Config requirements

db schema requires a driver entry in your config to open a database connection. A contract entry is not required since this command does not read or compare contract artifacts.
prisma-next.config.ts

Usage examples

Output formats

Column types in the output are native database types (int4, text, timestamptz), not Prisma Next codec IDs (pg/int4@1). This reflects the actual database state and may differ from the codec mappings defined in your contract.

Introspection process

The command follows these steps internally:
  1. Connects to the database using config.driver.create(url).
  2. Builds a ControlStack and creates a family instance via config.family.create(stack).
  3. Calls familyInstance.introspect() to query the database catalog and return a family-specific schema IR (for example, SqlSchemaIR for the SQL family).
  4. Calls familyInstance.toSchemaView() to project the schema IR into a CoreSchemaView for display.
  5. Renders the CoreSchemaView as a tree (TTY) or JSON envelope (--json).

Error codes

To capture a baseline snapshot of your database schema before making changes, pipe the JSON output to a file: prisma-next db schema --json > schema-snapshot.json. You can diff two snapshots to understand what changed between deployments.