From ded17a498aaed63a80fe0bbf4d184aa3e468b023 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Sep 2014 17:31:38 +0200 Subject: schema loading rake tasks maintain database connection for current env. [Joshua Cody & Yves Senn] Closes #16757. Prior to this patch schema loading rake tasks had the potential to leak a connection to a different database. This had side-effects when rake tasks operating on the current connection (like `db:seed`) were chained. --- activerecord/lib/active_record/tasks/database_tasks.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 331c1b7b63..f9b54139d5 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -171,6 +171,7 @@ module ActiveRecord each_current_configuration(environment) { |configuration| purge configuration } + ActiveRecord::Base.establish_connection(environment.to_sym) end def structure_dump(*arguments) @@ -217,6 +218,7 @@ module ActiveRecord each_current_configuration(environment) { |configuration| load_schema_for configuration, format, file } + ActiveRecord::Base.establish_connection(environment.to_sym) end def check_schema_file(filename) -- cgit v1.2.3