提交 2a9b3abe 编写于 作者: A Aaron Patterson

Merge pull request #1229 from workmad3/master

Fix for Issue #1205
......@@ -79,8 +79,10 @@ def invert_rename_column(args)
end
def invert_add_index(args)
table, columns, _ = *args
[:remove_index, [table, {:column => columns}]]
table, columns, options = *args
index_name = options.try(:[], :name)
options_hash = index_name ? {:name => index_name} : {:column => columns}
[:remove_index, [table, options_hash]]
end
def invert_remove_timestamps(args)
......
......@@ -86,6 +86,18 @@ def test_invert_add_index
assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove
end
def test_invert_add_index_with_name
@recorder.record :add_index, [:table, [:one, :two], {:name => "new_index"}]
remove = @recorder.inverse.first
assert_equal [:remove_index, [:table, {:name => "new_index"}]], remove
end
def test_invert_add_index_with_no_options
@recorder.record :add_index, [:table, [:one, :two]]
remove = @recorder.inverse.first
assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove
end
def test_invert_rename_index
@recorder.record :rename_index, [:old, :new]
rename = @recorder.inverse.first
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册