提交 b2a25948 编写于 作者: R Rafael Mendonça França

Merge pull request #21336 from yui-knk/refactor/to_use_getter

Use `ActiveRecord::Migration#connection` instead of `@connection`
......@@ -475,13 +475,13 @@ def initialize(name = self.class.name, version = nil)
def revert(*migration_classes)
run(*migration_classes.reverse, revert: true) unless migration_classes.empty?
if block_given?
if @connection.respond_to? :revert
@connection.revert { yield }
if connection.respond_to? :revert
connection.revert { yield }
else
recorder = CommandRecorder.new(@connection)
recorder = CommandRecorder.new(connection)
@connection = recorder
suppress_messages do
@connection.revert { yield }
connection.revert { yield }
end
@connection = recorder.delegate
recorder.commands.each do |cmd, args, block|
......@@ -492,7 +492,7 @@ def revert(*migration_classes)
end
def reverting?
@connection.respond_to?(:reverting) && @connection.reverting
connection.respond_to?(:reverting) && connection.reverting
end
class ReversibleBlockHelper < Struct.new(:reverting) # :nodoc:
......@@ -549,7 +549,7 @@ def run(*migration_classes)
revert { run(*migration_classes, direction: dir, revert: true) }
else
migration_classes.each do |migration_class|
migration_class.new.exec_migration(@connection, dir)
migration_class.new.exec_migration(connection, dir)
end
end
end
......@@ -641,7 +641,7 @@ def method_missing(method, *arguments, &block)
arg_list = arguments.map(&:inspect) * ', '
say_with_time "#{method}(#{arg_list})" do
unless @connection.respond_to? :revert
unless connection.respond_to? :revert
unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method)
arguments[0] = proper_table_name(arguments.first, table_name_options)
if [:rename_table, :add_foreign_key].include?(method) ||
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册