From 24653c945ad3fdce4cb5890a9cc7565753decda0 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Mon, 6 Aug 2012 22:20:34 -0400 Subject: Extract exec_migration [#8267] --- activerecord/lib/active_record/migration.rb | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index b292b35ff4..14c1fb9ae2 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -445,17 +445,7 @@ module ActiveRecord time = nil ActiveRecord::Base.connection_pool.with_connection do |conn| time = Benchmark.measure do - @connection = conn - if respond_to?(:change) - if direction == :down - revert { change } - else - change - end - else - send(direction) - end - @connection = nil + exec_migration(conn, direction) end end @@ -465,6 +455,21 @@ module ActiveRecord end end + def exec_migration(conn, direction) + @connection = conn + if respond_to?(:change) + if direction == :down + revert { change } + else + change + end + else + send(direction) + end + ensure + @connection = nil + end + def write(text="") puts(text) if verbose end -- cgit v1.2.3