Skip to content

Instantly share code, notes, and snippets.

@JustinLove
Created August 2, 2012 14:56
Show Gist options
  • Save JustinLove/3237640 to your computer and use it in GitHub Desktop.
Save JustinLove/3237640 to your computer and use it in GitHub Desktop.
Migrate from Heroku shared database to new database plans (dev currently embedded)
# ruby migrate.rb <app-name>
app = ARGV[0]
require 'heroku'
hc = Heroku::Client.new(ENV['HEROKU_USER'], ENV['HEROKU_PASS'])
response = hc.install_addon(app, 'heroku-postgresql:dev')
puts response
db = response['message'][/HEROKU_POSTGRESQL_\w+/]
puts hc.install_addon(app, 'pgbackups')
hc.maintenance(app, :on)
system("heroku pgbackups:capture --expire --app #{app}")
system("heroku pgbackups:restore #{db} --confirm #{app} --app #{app}")
system("heroku pg:promote #{db} --app #{app}")
hc.maintenance(app, :off)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment