Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Command

prisma migrate deploy

Applies all pending Prisma Migrate migrations to a staging or production database, creating the database if necessary. It is designed for automated deployment environments.

How it works

The command reads the Prisma configuration and migration history, compares recorded migrations with the database, then applies every pending migration and records the result. It is intended for staging, testing, and production rather than creating or changing migrations during development.

Syntax

prisma migrate deploy [options]

Parameters

NameTypeDescription
--configstringOptional path to a custom Prisma configuration file.
--schemastringOptional path to a custom Prisma schema file.
-h, --helpflagDisplays command help.

Returns

Applies pending migrations and exits with a command status; it does not generate artifacts or reset the database.

Key points

  • Use the command to update a non-development database with migrations that already exist in the migration directory.
  • Every migration not yet applied is processed in order.
  • If the configured database is absent, the command can create it before applying migrations.
  • The target connection is obtained from the Prisma configuration, such as prisma.config.ts.
  • Deployment does not require a shadow database.
  • Use --config when the Prisma config is outside its default location.

Common mistakes

  • It does not detect schema drift or ungenerated Prisma schema changes; review and create migrations separately.
  • It neither resets the database nor generates client or other artifacts.
  • Prefer an automated CI/CD pipeline instead of running the production deployment locally.
  • Ensure the deployment environment installs the Prisma CLI dependency, including when production installs omit development dependencies.

Example: Apply pending migrations

npx prisma migrate deploy

Run this command in a CI/CD deployment step to apply committed migrations to the target database.

When to use it

Staging deployment

A release pipeline updates a staging database before deploying the application.

Production deployment

A production release applies migration files committed with the application version.

Custom project paths

A deployment targets a non-default Prisma config or schema location.

Interview questions

QWhat does prisma migrate deploy do?

It applies all pending migrations to a staging, testing, or production database. The migration files should be committed and the command is normally executed by CI/CD.

Follow-up: What does it do with an already-applied migration that was edited? It compares the applied migration history and warns when migrations have been modified.

QHow does Prisma Migrate track deployment state?

The command compares applied migrations with the migration history, applies pending migrations, and updates the database's migration records. It does not create a new migration from schema changes.

Follow-up: How would you handle an existing database without migration history? Baseline it first, then use the resulting migration history for later deployments.

QHow should this command be integrated into deployment?

Use a package-runner command such as npx prisma migrate deploy in a release or CI/CD step. The Prisma config supplies the datasource URL, and optional flags can select a custom config or schema path.

Follow-up: Which environment should generate migrations? Development should generate and review them; deployment environments should apply committed pending migrations.

  • prisma migrate dev
  • prisma migrate status
  • prisma.config.ts
  • Prisma Migrate
  • _prisma_migrations

Source: prisma migrate deploy | Apply Migrations to Production. Checked 2026-10-16.