Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

db migrate

db migrate applies pending on-disk migrations to advance the database. It walks every contract space (app and extensions) and applies migrations in canonical order: extensions alphabetically, then the app. It applies only the migrations that exist on disk and never generates new operations.

Use it from a controlled deployment step after reviewing migration packages.

title="bun"
bunx prisma db migrate --db "$DATABASE_URL"
pnpm
pnpm prisma db migrate --db "$DATABASE_URL"
yarn
yarn prisma db migrate --db "$DATABASE_URL"
npm
npx prisma db migrate --db "$DATABASE_URL"
Option What it does
--db <url> Connects to the database.
--to <contract> Applies migrations up to a target contract (hash, prefix, ref name, migration directory name, <dir>^, or ./path).
--advance-ref <name> Advances the named ref to the post-apply marker after success.
--show Previews the migration route without applying (read-only).
--from <contract> Sets the from-state for the --show preview: @contract (the emitted contract), @db (the database's current marker), a hash, a ref name, or a migration directory.
--config <path> Read this config file instead of ./prisma.config.ts.
--json Prints a machine-readable result.
title="bun"
bunx prisma migration status --db "$DATABASE_URL"

bunx prisma db migrate --db "$DATABASE_URL"

bunx prisma migration status --db "$DATABASE_URL"

bunx prisma db verify --db "$DATABASE_URL"
pnpm
pnpm prisma migration status --db "$DATABASE_URL"
pnpm prisma db migrate --db "$DATABASE_URL"
pnpm prisma migration status --db "$DATABASE_URL"
pnpm prisma db verify --db "$DATABASE_URL"
yarn
yarn prisma migration status --db "$DATABASE_URL"
yarn prisma db migrate --db "$DATABASE_URL"
yarn prisma migration status --db "$DATABASE_URL"
yarn prisma db verify --db "$DATABASE_URL"
npm
npx prisma migration status --db "$DATABASE_URL"
npx prisma db migrate --db "$DATABASE_URL"
npx prisma migration status --db "$DATABASE_URL"
npx prisma db verify --db "$DATABASE_URL"

Run migration status before and after applying migrations to see what changed.

--show prints the route db migrate would take without touching the database:

title="bun"
bunx prisma db migrate --show

bunx prisma db migrate --show --from @contract --to production
pnpm
pnpm prisma db migrate --show
pnpm prisma db migrate --show --from @contract --to production
yarn
yarn prisma db migrate --show
yarn prisma db migrate --show --from @contract --to production
npm
npx prisma db migrate --show
npx prisma db migrate --show --from @contract --to production

If your project uses named refs, apply up to a target ref:

bunx prisma db migrate --db "$DATABASE_URL" --to production
Bash
pnpm prisma db migrate --db "$DATABASE_URL" --to production
Bash
yarn prisma db migrate --db "$DATABASE_URL" --to production
Bash
npx prisma db migrate --db "$DATABASE_URL" --to production

Manage refs with migration ref.

Manage refs with migration ref.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu