lib/tasks/pg_pull.rake in effective_developer-0.5.2 vs lib/tasks/pg_pull.rake in effective_developer-0.5.3
- old
+ new
@@ -70,10 +70,11 @@
task :load, [:file_name] => :environment do |t, args|
args.with_defaults(:file_name => 'latest.dump')
config = ActiveRecord::Base.configurations[Rails.env]
db = { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
+ db.transform_values! { |v| v.respond_to?(:chomp) ? v.chomp : v }
puts "=== Loading #{args.file_name} into local '#{db[:database]}' database"
# bin/rails db:environment:set RAILS_ENV=development
if Rails.env != 'production'
@@ -103,9 +104,11 @@
{ username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
else
config = ActiveRecord::Base.configurations[Rails.env]
{ username: (config['username'] || `whoami`.chomp), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
end
+
+ db.transform_values! { |v| v.respond_to?(:chomp) ? v.chomp : v }
puts "=== Saving local '#{db[:database]}' database to #{args.file_name}"
if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.file_name}")
puts "Saving database completed"