Skip to content

Instantly share code, notes, and snippets.

@avsej
Created March 10, 2014 08:52
Show Gist options
  • Select an option

  • Save avsej/9461592 to your computer and use it in GitHub Desktop.

Select an option

Save avsej/9461592 to your computer and use it in GitHub Desktop.
diff --git i/lib/tasks/db.rake w/lib/tasks/db.rake
index a893c6c..0140f34 100644
--- i/lib/tasks/db.rake
+++ w/lib/tasks/db.rake
@@ -1,10 +1,10 @@
namespace :db do
desc "Dump data from PostgreSQL database"
task dump: :environment do
- config = YAML::load_file(Rails.root.join("config", "database.yml"))[Rails.env]
+ config = ActiveRecord::Base.configurations[Rails.env]
db_name = config['database']
uname = config['username']
- host = config['host']
+ host = config['host'] || config['socket']
out = Rails.root.join "tmp", "dump.sql"
sh = "`which pg_dump` -U#{uname} -w #{db_name} -h #{host} > #{out}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment