rembrembdocs

Workflows

How to use Prisma Migrate commands in development and production environments

In a development environment, use the migrate dev command to generate and apply migrations:

Create and apply migrations

This command:

The migrate dev command will prompt you to reset the database in the following scenarios:

Reset the development database

You can also reset the database yourself to undo manual changes or db push experiments by running:

This command:

For a simple and integrated way to re-create data in your development database as often as needed, check out our seeding guide.

Customizing migrations

Sometimes, you need to modify a migration before applying it. For example:

The --create-only command allows you to create a migration without applying it:

To apply the edited migration, run prisma migrate dev again.

Refer to Customizing migrations for examples.

Team development

See: Team development with Prisma Migrate .

In production and testing environments, use the migrate deploy command to apply migrations:

migrate deploy should generally be part of an automated CI/CD pipeline, and we do not recommend running this command locally to deploy changes to a production database.

This command:

The migrate deploy command:

See also:

Advisory locking

Prisma Migrate makes use of advisory locking when you run production commands such as:

This safeguard ensures that multiple commands cannot run at the same time - for example, if you merge two pull requests in quick succession.

Advisory locking has a 10 second timeout (not configurable), and uses the default advisory locking mechanism available in the underlying provider:

Prisma Migrate's implementation of advisory locking is purely to avoid catastrophic errors - if your command times out, you will need to run it again.

Since 5.3.0, the advisory locking can be disabled using the PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK environment variable