Deploying database changes with Prisma Migrate

To apply pending migrations to development, staging, or testing environments, run the migrate deploy command as part of your CI/CD pipeline:

$npx prisma migrate deploy

Exactly when to run prisma migrate deploy depends on your platform. For example, a simplified Heroku workflow includes:

  1. Ensuring the ./prisma/migration folder is in source control
  2. Running prisma migrate deploy during the release phase

Ideally, migrate deploy should be part of an automated CI/CD pipeline, and we do not generally recommend running this command locally to deploy changes to a production database (for example, by temporarily changing the DATABASE_URL environment variable). It is not generally considered good practice to store the production database URL locally.

Beware that in order to run the prisma migrate deploy command, you need access to the prisma dependency that is typically added to the devDependencies. Some platforms like Vercel, prune development dependencies during the build, thereby preventing you from calling the command. This can be worked around by making the prisma a production dependency, by moving it to dependencies in your package.json. For more information about the migrate deploy command, see:

Edit this page on GitHub