Rake task to create ~/.pgpass based on 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
Written by Jeremy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Heroku
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#