lib/tasks/pg_pull.rake in effective_developer-0.6.8 vs lib/tasks/pg_pull.rake in effective_developer-0.6.9
- old
+ new
@@ -16,12 +16,12 @@
env_keys = { database: ENV['DATABASE'], filename: ENV['FILENAME'] }
keywords = ARGV.map { |a| a.split('=') if a.include?('=') }.compact.inject({}) { |h, (k, v)| h[k.to_sym] = v; h }
args.with_defaults(defaults.compact.merge(env_keys.compact).merge(keywords))
# Validate Config
- config = ActiveRecord::Base.configurations[Rails.env]
configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
+ config = configs.first
if configs.length > 1 && args.database.blank?
puts "Multiple database configs exist for #{Rails.env} environment."
puts "Please run bundle exec rake pg:pull database=x"
puts "Where x is one of: #{configs.map { |config| config.name }.to_sentence}"
@@ -100,12 +100,12 @@
unless File.exists?(Rails.root + args.filename)
puts "#{args.filename || none} does not exist"; exit
end
# Validate Config
- config = ActiveRecord::Base.configurations[Rails.env]
configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
+ config = configs.first
if configs.length > 1 && args.database.blank?
puts "Multiple database configs exist for #{Rails.env} environment."
puts "Please run bundle exec rake pg:load database=x"
puts "Where x is one of: #{configs.map { |config| config.name }.to_sentence}"
@@ -149,11 +149,11 @@
abort("Invalid DATABASE_URL") unless uri.present?
{ username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
else
# Validate Config
- config = ActiveRecord::Base.configurations[Rails.env]
configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
+ config = configs.first
if configs.length > 1 && args.database.blank?
puts "Multiple database configs exist for #{Rails.env} environment."
puts "Please run bundle exec rake pg:save database=x"
puts "Where x is one of: #{configs.map { |config| config.name }.to_sentence}"