Permalink
Browse files

db:schema:load db:schema:dump: establish_connection(Rails.env) -> est…

…ablish_connection'

etablish_connection(Rails.env) messes up when DATABASE_URL points to a valid db,
but Rails.env points to an invalid config in config/database.yml.

The behavior of using DATABASE_URL first matches that of db:migrate.
  • Loading branch information...
1 parent f278b06 commit 1c9d522194dc08d55c1a8299147d5dc8224c381d @clacke committed Jun 14, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/railties/databases.rake
@@ -314,7 +314,7 @@ db_namespace = namespace :db do
task :load => :environment do
require 'active_record/fixtures'
- ActiveRecord::Base.establish_connection(Rails.env)
+ ActiveRecord::Base.establish_connection
base_dir = File.join [Rails.root, ENV['FIXTURES_PATH'] || %w{test fixtures}].flatten
fixtures_dir = File.join [base_dir, ENV['FIXTURES_DIR']].compact
@@ -353,7 +353,7 @@ db_namespace = namespace :db do
require 'active_record/schema_dumper'
filename = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
File.open(filename, "w:utf-8") do |file|
- ActiveRecord::Base.establish_connection(Rails.env)
+ ActiveRecord::Base.establish_connection
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
end
db_namespace['schema:dump'].reenable

0 comments on commit 1c9d522

Please sign in to comment.