Skip to content

Instantly share code, notes, and snippets.

@borisd
Created August 6, 2012 12:23
Show Gist options
  • Save borisd/3274046 to your computer and use it in GitHub Desktop.
Save borisd/3274046 to your computer and use it in GitHub Desktop.
Heroku SHARED DATABASE migration to PostgreSQL
if [ $# -eq 0 ] ; then
echo "No args given"
echo "Missing Heroku app name"
exit 1
fi
APP_NAME="--app ${1}"
echo "heroku addons:add heroku-postgresql:dev ${APP_NAME}"
heroku addons:add heroku-postgresql:dev ${APP_NAME}
echo
echo "heroku addons:add pgbackups:auto-week ${APP_NAME}"
heroku addons:add pgbackups:auto-week ${APP_NAME}
echo
echo "heroku maintenance:on ${APP_NAME}"
heroku maintenance:on ${APP_NAME}
echo
echo "Capture a backup of your current database:"
echo "heroku pgbackups:capture --expire ${APP_NAME}"
heroku pgbackups:capture --expire ${APP_NAME}
echo
COLOR=`heroku config ${APP_NAME} | grep POSTGRESQL | cut -d'_' -f 3`
echo "Restore the backup to your new db:"
echo "heroku pgbackups:restore HEROKU_POSTGRESQL_${COLOR} ${APP_NAME}"
heroku pgbackups:restore HEROKU_POSTGRESQL_${COLOR} ${APP_NAME}
echo
echo "Set your new database to be the primary database for your application:"
echo "heroku pg:promote HEROKU_POSTGRESQL_${COLOR} ${APP_NAME}"
heroku pg:promote HEROKU_POSTGRESQL_${COLOR} ${APP_NAME}
echo
echo "heroku maintenance:off"
heroku maintenance:off ${APP_NAME}
echo
echo "remove shared-database"
echo "heroku addons:remove shared-database ${APP_NAME}"
heroku addons:remove shared-database ${APP_NAME}
echo
echo "heroku pg:info ${APP_NAME}"
heroku pg:info ${APP_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment