Skip to content

DocsBuild and deploy

Deploy commands

Commands that run once for every deployment, before the new version takes traffic. The place for database migrations.

Deploy commands run once for every deployment, after the build and before the new version takes traffic. They are the place for work that has to happen once per release, such as a database migration.

Open Settings, Deploy commands, write one command per line and save:

npm run migrate

They are used from the next deployment on.

  • Once, not on every replica. They run on a separate, short-lived copy of the new version. That copy takes no traffic and is removed afterwards.
  • With your variables. All your environment variables are set, so a command can reach your database.
  • In order. The first command that fails stops the rest.
  • For up to 15 minutes in total.

The deployment fails and the app that is running is not changed. The deployment page shows the message:

Message Meaning
A deploy command failed (exit code N) A command ended with an error. Its output is in the build log
The deploy commands did not finish within 15 minutes They took too long
The deploy commands ran out of memory They need more memory than the size of the app has
Deployment Deploy commands
Git push, manual deploy Run
Restart, redeploy Run
Rollback Do not run
Domain change Do not run
  • Old code is still running. While a migration runs, the previous version still answers requests. Write migrations that the old code can live with.
  • A rollback does not undo them. Rolling back brings back old code, not old data.
  • Files they write are not kept. The copy they run on is thrown away. To create files for the app, use a build command.