title: ActiveRecord is resetting all my previously defined variables
body: <p>I'm building a rake task in order to migrate some data between two databases. The ones have exactly the same structure. My task is so:</p>
  
  <pre><code>namespace :oab_nexus_migration do
    task :start, [:oab_user, :nexus_user] =&gt; :environment do |t, args|
      oab_account      = User.find_by_username(args[:oab_user]).main_account
  
      oab_trials       = oab_account.trials.includes(:parts)
      oab_schedules    = oab_account.schedules
      oab_movements    = oab_account.movements
      oab_annotations  = oab_account.annotations
      oab_hearings     = oab_account.hearings
      oab_publications = oab_account.publications
      oab_tasks        = oab_account.tasks
      oab_people       = oab_account.people.includes(:addresses, :internet_addresses, :phones)
  
      ActiveRecord::Base.establish_connection(:other_database)
  
      ...
      More code here
    end
  end
  </code></pre>
  
  <p>The task is executed with:</p>
  
  <p><code>RAILS_ENV=production rake oab_nexus_migration:start[user_one, user_two]</code></p>
  
  <p>After retrieve all information I need from database one, I need to insert it into database two. But something really weird is happening. If I, for example, call <code>p oab_trials</code> (or any other variable) before <code>establish_connection</code>, all values are there, represented by a large array. But if I try to call it after <code>establish_connection</code>, the returned value is an empty array. Seems like ActiveRecord is resetting all my previously defined variables.</p>
  
  <p>What is happening here? </p>