Tarefa Rake para criar ~ / .pgpass com base em heroku: config

namespace :db do
require 'uri'
desc
"Uses heroku:config for APP to forcefully create ~/.pgpass"
task
:create_pgpass do
app
= ENV['APP'] || 'whatever-your-default-app-is'
uri
= URI(`heroku config:get DATABASE_URL -a #{app}`)
entry
= "*:5432:#{uri.path.gsub ///, ''}:#{uri.user}:#{uri.password}"
`echo '#{entry}' > ~/.pgpass; chmod 0600 ~/.pgpass`
end
end