This is a simple Node.js app to show the a database migration using Heroku's release phase.
There are two demo flows described below. The first shows release phase work as simply as possible. The second shows how release phase can easily be incorporated into Heroku Flow.
Fork this repo to your own GitHub account
Click ➡ https://github.com/heroku-demos/release-phase-demo/fork
Setup a Heroku Pipeline with staging and production apps
heroku pipelines:setup nodejs-release-phase
# provide your forked copy of the repository when prompted for one: <YOUR_GITHUB_USER>/release-phase-demo
# then answer No to all questions
# the name nodejs-release-phase is used to name the automatically create staging and production apps; if that name is being used by another app, this step will fail. Use a different name.
Git clone code locally and install dependencies with yarn
git clone [email protected]:<YOUR_GITHUB_USER>/release-phase-demo.git
cd release-phase-demo
yarn
Add staging app as git remote to which we will deploy
heroku git:remote -a nodejs-release-phase-staging
Update your environment PATH variable so sequelize
can be called without its full path. You'll have to re-run this any time you open a new shell.
declare -x PATH=$PATH:$(pwd)/node_modules/.bin
- Create migration for new table
sequelize model:create --name Post --attributes title:string,author:string,body:text
If thesequelize
command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from therelease-phase-demo
directory:declare -x PATH=$PATH:$(pwd)/node_modules/.bin
- Add
release
line in Procfile. This is what executes the migration after build but before deploy. - Add and commit new model and migration files and updated Procfile
git add migrations models Procfile
git commit -m 'Add Post model'
- Deploy and show CLI ouput, highlighting release phase migration output at the end.
git push heroku master
- Show that the app now has a Post table!
heroku open
Pre-demo prep
- Create migration for new table
sequelize model:create --name Post --attributes title:string,author:string,body:text
If thesequelize
command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from therelease-phase-demo
directory:declare -x PATH=$PATH:$(pwd)/node_modules/.bin
- Add and commit new model and migration files.
git add migrations models
git commit -m 'Add Post model'
Demo!
- Add
release
line in Procfile. This is what executes the migration after build but before deploy. - Show current state of app, highlighting the one table
heroku open
- Add and commit updated Procfile
git commit -am 'Add release task to Procfile'
- Deploy and show CLI ouput, highlighting release phase migration output at the end.
git push heroku master
- Show that the app now has two tables including the Post table!
heroku open
- Show pipeline
- Show current state of app
Select "Open app in browser" from pipeline's staging app - Create new table by creating a new model and migration
sequelize model:create --name Post --attributes title:string,author:string,body:text
If thesequelize
command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from therelease-phase-demo
directory to do that:declare -x PATH=$PATH:$(pwd)/node_modules/.bin
- Add
release
line in Procfile. This is what executes the migration after build but before deploy. - Add and commit new model and migration files and updated Procfile
git add migrations models Procfile
git commit -m 'Add Post model'
- Deploy and show CLI ouput (not split screen).
git push heroku master
- When build and deploy are finished, open staging app (which shows new DB structure created by our migration)
Select "Open app in browser" from staging app - In the pipeline dashboard, promote app from staging to production. This will cause release phase to run again.
- Show release phase running on the "production" card UI and expand the "Releasing" dialog
Setup
docker-compose up -d
yarn
sequelize db:migrate
If the sequelize
command does not work, you probably need to add its directory to your PATH. Run this command from the release-phase-demo
directory: declare -x PATH=$PATH:$(pwd)/node_modules/.bin
Run
npm start
# Open localhost:3000
Finish
docker-compose down