diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-18 15:53:59 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-18 15:53:59 -0800 |
commit | 07a74f196d6766c09e28ed696debb120a035dde7 (patch) | |
tree | 7b46ebf26b783ae3c454ae5083d950933390b2a2 /activerecord/lib | |
parent | e107dcca6b132d39f578b48fba39891eaf902a0d (diff) | |
download | rails-07a74f196d6766c09e28ed696debb120a035dde7.tar.gz rails-07a74f196d6766c09e28ed696debb120a035dde7.tar.bz2 rails-07a74f196d6766c09e28ed696debb120a035dde7.zip |
connection is set from the connection pool during migrations
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 0eabc4a4aa..06a8747fde 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -300,8 +300,9 @@ module ActiveRecord attr_accessor :name, :version def initialize - @name = self.class.name - @version = nil + @name = self.class.name + @version = nil + @connection = nil end def up @@ -326,7 +327,12 @@ module ActiveRecord end result = nil - time = Benchmark.measure { result = send(direction) } + time = nil + ActiveRecord::Base.connection_pool.with_connection do |conn| + @connection = conn + time = Benchmark.measure { result = send(direction) } + @connection = nil + end case direction when :up then announce "migrated (%.4fs)" % time.real; write @@ -367,7 +373,7 @@ module ActiveRecord end def connection - ActiveRecord::Base.connection + @connection || ActiveRecord::Base.connection end def method_missing(method, *arguments, &block) |