Staging deployment
A release pipeline updates a staging database before deploying the application.
Prisma · Command
Applies all pending Prisma Migrate migrations to a staging or production database, creating the database if necessary. It is designed for automated deployment environments.
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.
prisma migrate deploy [options]| Name | Type | Description |
|---|---|---|
--config | string | Optional path to a custom Prisma configuration file. |
--schema | string | Optional path to a custom Prisma schema file. |
-h, --help | flag | Displays command help. |
Applies pending migrations and exits with a command status; it does not generate artifacts or reset the database.
prisma.config.ts.--config when the Prisma config is outside its default location.npx prisma migrate deployRun this command in a CI/CD deployment step to apply committed migrations to the target database.
A release pipeline updates a staging database before deploying the application.
A production release applies migration files committed with the application version.
A deployment targets a non-default Prisma config or schema location.
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.
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.
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 devprisma migrate statusprisma.config.tsPrisma Migrate_prisma_migrations