Created
August 4, 2012 10:00
-
-
Save lenary/3256490 to your computer and use it in GitHub Desktop.
Auto-migrator for heroku databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ALL destructive actions still need to be confirmed manually by the user. | |
# It's also worth pointing out that in special cases, things may not work. | |
# Most of this info is gleaned from https://devcenter.heroku.com/articles/migrating-from-shared-database-to-heroku-postgres | |
set -e | |
APP=$1 | |
echo "APP = $APP" | |
heroku addons:add heroku-postgresql:dev -a $APP | |
heroku addons:add pgbackups -a $APP | |
heroku maintenance:on -a $APP | |
heroku pgbackups:capture --expire -a $APP | |
COLOUR_URL=`heroku config -a $APP | grep HEROKU_POSTGRESQL | cut -f 1 -d ":" | head -1` | |
COLOUR_STRING=`heroku config -a $APP | grep HEROKU_POSTGRESQL | cut -f 1-3 -d "_" | head -1` | |
echo "COLOUR_URL = $COLOUR_URL; COLOUR_STRING = $COLOUR_STRING" | |
heroku pgbackups:restore $COLOUR_URL -a $APP | |
heroku pg:promote $COLOUR_STRING -a $APP | |
heroku maintenance:off -a $APP | |
heroku addons:remove shared-database -a $APP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment