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.
bunx prisma db migrate --db "$DATABASE_URL"pnpm prisma db migrate --db "$DATABASE_URL"yarn prisma db migrate --db "$DATABASE_URL"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. |
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 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 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"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:
bunx prisma db migrate --show
bunx prisma db migrate --show --from @contract --to productionpnpm prisma db migrate --show
pnpm prisma db migrate --show --from @contract --to productionyarn prisma db migrate --show
yarn prisma db migrate --show --from @contract --to productionnpx prisma db migrate --show
npx prisma db migrate --show --from @contract --to productionIf your project uses named refs, apply up to a target ref:
bunx prisma db migrate --db "$DATABASE_URL" --to productionpnpm prisma db migrate --db "$DATABASE_URL" --to productionyarn prisma db migrate --db "$DATABASE_URL" --to productionnpx prisma db migrate --db "$DATABASE_URL" --to productionManage refs with migration ref.
Manage refs with migration ref.