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.

prisma-next db update applies the full set of operations required to bring any database — whether bootstrapped with db init or not — into alignment with the currently emitted contract.json. Unlike db init, it permits widening and destructive operations in addition to purely additive ones. db update creates the signature table if it is missing, so it can operate on databases that have never been touched by Prisma Next. In --dry-run mode for SQL targets, it prints a DDL preview derived from the planned operations so you can review the exact statements before committing.
Destructive operations — such as dropping columns or tables — require explicit confirmation. In interactive terminals, db update prompts before applying any destructive plan. In non-interactive environments (CI, scripts), the command fails unless you pass -y / --yes. This is intentional to prevent accidental data loss.

Options

query.--db
string
Database connection string. Optional when db.connection is set in your config file.
query.--config
string
Path to prisma-next.config.ts. Defaults to ./prisma-next.config.ts in the current working directory.
query.--dry-run
boolean
Print the migration plan and, for SQL targets, a DDL preview of the planned operations. No changes are applied.
query.-y / --yes
boolean
Skip confirmation prompts. Required when running in non-interactive mode with a destructive plan.
query.--interactive / --no-interactive
boolean
Override automatic TTY detection. Use --no-interactive to force non-interactive mode in environments that report an interactive terminal but should not receive prompts.
query.--json
string
Output a JSON result envelope to stdout.
query.-q
boolean
Quiet mode. Suppresses all output except errors.
query.-v
boolean
Verbose mode. Prints debug information and timing data.

Config requirements

db update requires a driver entry in your config to open a database connection. A contract entry must point to a valid emitted contract.json. The driver field is not needed if you only use --dry-run, but it is always required for an apply.
prisma-next.config.ts
import { defineConfig } from '@prisma-next/cli/config-types';
import { typescriptContract } from '@prisma-next/sql-contract-ts/config-types';
import postgresAdapter from '@prisma-next/adapter-postgres/control';
import postgresDriver from '@prisma-next/driver-postgres/control';
import postgres from '@prisma-next/target-postgres/control';
import sql from '@prisma-next/family-sql/control';
import { contract } from './prisma/contract';

export default defineConfig({
  family: sql,
  target: postgres,
  adapter: postgresAdapter,
  driver: postgresDriver,
  extensionPacks: [],
  contract: typescriptContract(contract, 'src/prisma/contract.json'),
  db: {
    connection: process.env.DATABASE_URL,
  },
});

Usage examples

# Apply changes using config defaults
prisma-next db update

# Preview DDL without applying
prisma-next db update --dry-run

# Apply with explicit database URL
prisma-next db update --db postgresql://user:pass@localhost/db

# Unattended apply (CI) — confirms destructive operations automatically
prisma-next db update -y

# JSON output for scripting
prisma-next db update --json

Dry-run DDL preview

When --dry-run is passed against a SQL target, db update prints a DDL preview alongside the operation plan. This lets you see the exact SQL statements that would be executed before committing to an apply.
TTY — dry-run with DDL preview
prisma-next db update ➜ Update database schema to match the current contract
  config:          prisma-next.config.ts
  contract:        src/prisma/contract.json
  mode:            plan (dry run)

✔ Planned 2 operation(s)

├─ Add column bio on user [additive]
└─ Drop column legacy_name on user [destructive]

DDL preview:
  ALTER TABLE "user" ADD COLUMN "bio" text;
  ALTER TABLE "user" DROP COLUMN "legacy_name";

This is a dry run. No changes were applied.
Run without --dry-run to apply changes.

Differences from db init

db initdb update
Operation classesAdditive onlyAdditive, widening, destructive
Existing marker requiredNo (fails if marker hash mismatches)No (creates signature table if missing)
Per-operation runner checksEnabledDisabled by default
Destructive confirmationN/ARequired (interactive prompt or -y)
Primary use caseFresh database bootstrapOngoing schema evolution

Error codes

CodeMeaning
PN-CLI-4005Missing database connection. Provide --db <url> or set db.connection in config.
PN-CLI-4010Missing driver in config. Add a driver descriptor to your config.
RUNNER_FAILEDThe runner rejected the apply due to an origin mismatch, failed checks, policy failures, or execution errors.

Build docs developers (and LLMs) love