aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorHubert DÄ…browski <h@dabrow.org>2014-02-12 22:23:16 +0100
committerHubert DÄ…browski <h@dabrow.org>2014-02-13 17:18:16 +0100
commite1d4673102f7c4e58964a6de864402ae9a615688 (patch)
tree636ea2effaf872112186d00b7a91b91db05102db /activerecord/lib
parent4dc42045e20114783a17a0c286b065a3969e6025 (diff)
downloadrails-e1d4673102f7c4e58964a6de864402ae9a615688.tar.gz
rails-e1d4673102f7c4e58964a6de864402ae9a615688.tar.bz2
rails-e1d4673102f7c4e58964a6de864402ae9a615688.zip
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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/migration/command_recorder.rb7
1 files changed, 6 insertions, 1 deletions
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)