Permalink
Browse files

Extract exec_migration [#8267]

  • Loading branch information...
1 parent d327c18 commit 24653c945ad3fdce4cb5890a9cc7565753decda0 @marcandre marcandre committed Aug 7, 2012
Showing with 16 additions and 11 deletions.
  1. +16 −11 activerecord/lib/active_record/migration.rb
@@ -445,17 +445,7 @@ def migrate(direction)
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 @@ def migrate(direction)
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

0 comments on commit 24653c9

Please sign in to comment.