diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-11 15:58:38 +0900 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-11 15:58:38 +0900 |
commit | bbaad89ba892b76e581a122893e628dbd306ac7e (patch) | |
tree | 655ef442d941979c216dca3f56bf48d973febba6 /activerecord/lib/active_record/railties | |
parent | e5249a7970251ed802dd895963fe9734c4ec1064 (diff) | |
download | rails-bbaad89ba892b76e581a122893e628dbd306ac7e.tar.gz rails-bbaad89ba892b76e581a122893e628dbd306ac7e.tar.bz2 rails-bbaad89ba892b76e581a122893e628dbd306ac7e.zip |
only reconnect if there was already an active connection
If you're using an in-memory database for the test database,
reconnecting will lose all information that schema:load did for us.
Diffstat (limited to 'activerecord/lib/active_record/railties')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 8a311039d5..daccab762f 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -320,11 +320,14 @@ db_namespace = namespace :db do # desc "Recreate the test database from an existent schema.rb file" task :load_schema => 'db:test:purge' do begin + should_reconnect = ActiveRecord::Base.connection_pool.active_connection? ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) ActiveRecord::Schema.verbose = false db_namespace["schema:load"].invoke ensure - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ActiveRecord::Tasks::DatabaseTasks.env]) + if should_reconnect + ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ActiveRecord::Tasks::DatabaseTasks.env]) + end end end |