You’re using acontinuous delivery pipeline because it takes the manual steps out of code deployment. But when a release includes updates to a database schema, the deployment requires manual intervention and team coordination. Typically, someone on the team will log into the database and run the migration, then quickly deploy the new code to production. It’s a process rife with deployment risk.
Now with Release Phase, generally available today, you can define tasks you need to run before a release is deployed to production. Simply push your code and Release Phase will automatically run your database schema migration, upload static assets to a CDN, or any other task your app needs to be ready for production. If a Release Phase task fails, the new release is not deployed, leaving the production release unaffected.
To get started, view the release phase documentation .
A Release Phase Example
Let’s say you have a Node.js app, using Sequelize as your ORM, and want to run a database migration on your next release. Simply define a release command in your Procfile:
release: node_modules/.bin/sequelize db:migrate web: node ./bin/www
When you run
git push heroku master , after the build is successful, Release Phase begins the migration via aone-off dyno. If the migration is successful, the app code is deployed to production. If the migration fails, your release is not deployed and you can check your Release Phase logs to debug.
$ git push heroku master ... Running release command…. --- Migrating Db --- Sequelize [Node: 7.9.0, CLI: 2.7.9, ORM: 3.30.4] Loaded configuration file "config/config.json". Using environment "production". == 20170413204504-create-post: migrating ====== == 20170413204504-create-post: migrated (0.054s) V23 successfully deployed
Check out the video to watch it in action:
Heroku Flow + Release Phase
Heroku Flow provides you with a professional continuous delivery pipeline with dev, staging, and production environments. When you promote a release from staging to production, Release Phase will automatically run your tasks in the production environment.
With Heroku Flow you always knows where a particular feature is on the path to production. Now — with Release Phase — the path to production has even fewer manual steps.