lib/fourchette/heroku.rb in fourchette-0.0.8 vs lib/fourchette/heroku.rb in fourchette-0.1.0

- old
+ new

@@ -61,13 +61,17 @@ end end end def copy_pg from, to - logger.info "Copying Postgres's data from #{from} to #{to}" - backup = Fourchette::Pgbackups.new - backup.copy(from, to) + if pg_enabled?(from) + logger.info "Copying Postgres's data from #{from} to #{to}" + backup = Fourchette::Pgbackups.new + backup.copy(from, to) + else + logger.info "Postgres not enabled on #{from}. Skipping data copy." + end end def copy_RACK_AND_RAILS_ENV_again(from, to) env_to_update = get_original_env(from) unless env_to_update.empty? @@ -81,7 +85,13 @@ if client.config_var.info(from)[var] environments[var] = client.config_var.info(from)[var] end end environments + end + + def pg_enabled?(app) + client.addon.list(app).any? do |addon| + addon['addon_service']['name'] == 'heroku-postgresql' + end end end