diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-21 19:20:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-21 19:20:23 +0900 |
commit | 30ae39efc22c3eae10260c0a3bde5cd0d2553f2f (patch) | |
tree | 146d208ddccd82bc811c7878bbdc9d5c192e0505 /activerecord | |
parent | e0f4ccabb83a681397f98f216f5c1f65a5969bbe (diff) | |
parent | 611f2b2911197946bd81d5d5fb017e7133d77d2f (diff) | |
download | rails-30ae39efc22c3eae10260c0a3bde5cd0d2553f2f.tar.gz rails-30ae39efc22c3eae10260c0a3bde5cd0d2553f2f.tar.bz2 rails-30ae39efc22c3eae10260c0a3bde5cd0d2553f2f.zip |
Merge pull request #24199 from meinac/fix_invert_add_index
Use algorithm while removing index with db:rollback
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration/command_recorder.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/migration/command_recorder_test.rb | 5 |
3 files changed, 13 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 55c4214eee..c34236d4be 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* Use given algorithm while removing index from database. + + Fixes #24190. + + *Mehmet Emin İNAÇ* + * Update payload names for `sql.active_record` instrumentation to be more descriptive. diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb index a3a5e0fa16..ac7d506fd1 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -161,8 +161,8 @@ module ActiveRecord table, columns, options = *args options ||= {} - index_name = options[:name] - options_hash = index_name ? { name: index_name } : { column: columns } + options_hash = options.slice(:name, :algorithm) + options_hash[:column] = columns if !options_hash[:name] [:remove_index, [table, options_hash]] end diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb index 0b5e983f14..58bc558619 100644 --- a/activerecord/test/cases/migration/command_recorder_test.rb +++ b/activerecord/test/cases/migration/command_recorder_test.rb @@ -213,6 +213,11 @@ module ActiveRecord assert_equal [:remove_index, [:table, { name: "new_index" }]], remove end + def test_invert_add_index_with_algorithm_option + remove = @recorder.inverse_of :add_index, [:table, :one, algorithm: :concurrently] + assert_equal [:remove_index, [:table, { column: :one, algorithm: :concurrently }]], remove + end + def test_invert_remove_index add = @recorder.inverse_of :remove_index, [:table, :one] assert_equal [:add_index, [:table, :one]], add |