Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Forked from jnf/pgpass.rake
Created January 22, 2013 15:15
Show Gist options
  • Save ninjapanzer/4595366 to your computer and use it in GitHub Desktop.
Save ninjapanzer/4595366 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment