Created
August 2, 2012 10:28
Revisions
-
pcreux revised this gist
Aug 2, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def db_name heroku! "pgbackups:restore #{db_name} --confirm #{app_name}" heroku! "pg:promote #{db_name}" heroku! "maintenance:off" heroku! "addons:remove shared-database --confirm #{app_name}" puts "Done!" -
pcreux revised this gist
Aug 2, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -45,6 +45,7 @@ def db_name heroku! "pgbackups:restore #{db_name} --confirm #{app_name}" heroku! "pg:promote #{db_name}" heroku! "maintenance:off" heroku! "addons:remove shared-database --confirm#{app_name}" puts "Done!" -
pcreux revised this gist
Aug 2, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,8 @@ def app_name def heroku(cmd) full_cmd = "heroku #{cmd} -a #{app_name}" puts full_cmd system full_cmd end def heroku!(cmd) -
pcreux created this gist
Aug 2, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #!/usr/bin/env ruby # # This script migrates your Heroku app from a Shared DB to a Postgres `dev` Plan # # Usage: # ruby migrate.rb [app_name] # def usage puts "migrate.rb [app_name]" exit 0 end def app_name ARGV.first or usage end def heroku(cmd) full_cmd = "heroku #{cmd} -a #{app_name}" puts full_cmd system full_cmd true end def heroku!(cmd) heroku(cmd) or exit 1 end def db_name return @db_name if @db_name config_output = `heroku config -a #{app_name} | grep POSTGRESQL` @db_name = config_output.match(/(HEROKU_POSTGRESQL_\w+)_URL/)[1] raise "Can't extract db_color from config_output" if @db_name.nil? @db_name end puts "Let's migrate #{app_name} over to Heroku Postgres Dev Plan" heroku "addons:add heroku-postgresql:dev" heroku "addons:add pgbackups" heroku! "maintenance:on" heroku! "pgbackups:capture --expire" heroku! "pgbackups:restore #{db_name} --confirm #{app_name}" heroku! "pg:promote #{db_name}" heroku! "maintenance:off" puts "Done!"