Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created August 27, 2020 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/0ed86cacfd527ea5d7d27b129b4e6c3c to your computer and use it in GitHub Desktop.
Save IanVaughan/0ed86cacfd527ea5d7d27b129b4e6c3c to your computer and use it in GitHub Desktop.
Steps to Upgrade a Heroku DB in a script
#!/usr/bin/env bash
# https://devcenter.heroku.com/articles/updating-heroku-postgres-databases#updating-with-follower-changeover
APP=name-production # name-staging
heroku addons:create heroku-postgresql:standard-2 --follow DATABASE_URL --app $APP # DONE
heroku addons:wait # DONE
for (( ; ; )); do; heroku pg:info --app $APP | grep Behind; sleep 1; done # DONE
heroku maintenance:on --app $APP
heroku ps:scale worker=0 --app $APP
heroku pg:info --app $APP
heroku pg:unfollow DATABASE_URL --app $APP
heroku pg:promote HEROKU_POSTGRESQL_TEAL_URL --app $APP
heroku ps:scale worker=1 --app $APP
heroku maintenance:off --app $APP
heroku addons:destroy HEROKU_POSTGRESQL_ORANGE_URL
heroku addons:destroy HEROKU_POSTGRESQL_SILVER_URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment