diff options
author | Hubert DÄ…browski <h@dabrow.org> | 2014-02-12 22:23:16 +0100 |
---|---|---|
committer | Hubert DÄ…browski <h@dabrow.org> | 2014-02-13 17:18:16 +0100 |
commit | e1d4673102f7c4e58964a6de864402ae9a615688 (patch) | |
tree | 636ea2effaf872112186d00b7a91b91db05102db /activerecord/lib | |
parent | 4dc42045e20114783a17a0c286b065a3969e6025 (diff) | |
download | rails-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.rb | 7 |
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) |