mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
@@ -79,8 +79,10 @@ module ActiveRecord
|
||||
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 @@ module ActiveRecord
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user