From e1d4673102f7c4e58964a6de864402ae9a615688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20D=C4=85browski?= Date: Wed, 12 Feb 2014 22:23:16 +0100 Subject: Drop the correct index after reverting a migration Previously when reverting a migration which added a named index it would instead drop a corresponding index with matching columns but without a name. --- activerecord/lib/active_record/migration/command_recorder.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb index 9139ad953c..c44d8c1665 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -140,7 +140,12 @@ module ActiveRecord def invert_add_index(args) table, columns, options = *args - [:remove_index, [table, (options || {}).merge(column: columns)]] + options ||= {} + + index_name = options[:name] + options_hash = index_name ? { name: index_name } : { column: columns } + + [:remove_index, [table, options_hash]] end def invert_remove_index(args) -- cgit v1.2.3