Skip to content

Instantly share code, notes, and snippets.

@katsuyoshi
Created August 8, 2012 06:54
Show Gist options
  • Save katsuyoshi/3292914 to your computer and use it in GitHub Desktop.
Save katsuyoshi/3292914 to your computer and use it in GitHub Desktop.
herokuのmigration
your_app = ARGV[0] || "your_app"
plan = ARGV[1] || "dev"
/(HEROKU_POSTGRESQL_\w+)/ =~ `heroku addons:add heroku-postgresql:#{plan} -a #{your_app}`
db_url = $1
system("heroku addons:add pgbackups -a #{your_app}")
system("heroku maintenance:on -a #{your_app}")
system("heroku pgbackups:capture --expire -a #{your_app}")
system("heroku pgbackups:restore #{db_url} -a #{your_app}")
system("heroku pg:promote #{db_url} -a #{your_app}")
system("heroku maintenance:off -a #{your_app}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment