summaryrefslogtreecommitdiff
path: root/rubocop/cop/migration/remove_index.rb
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/cop/migration/remove_index.rb')
-rw-r--r--rubocop/cop/migration/remove_index.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/rubocop/cop/migration/remove_index.rb b/rubocop/cop/migration/remove_index.rb
new file mode 100644
index 00000000000..613b35dd00d
--- /dev/null
+++ b/rubocop/cop/migration/remove_index.rb
@@ -0,0 +1,26 @@
+require_relative '../../migration_helpers'
+
+module RuboCop
+ module Cop
+ module Migration
+ # Cop that checks if indexes are removed in a concurrent manner.
+ class RemoveIndex < RuboCop::Cop::Cop
+ include MigrationHelpers
+
+ MSG = '`remove_index` requires downtime, use `remove_concurrent_index` instead'.freeze
+
+ def on_def(node)
+ return unless in_migration?(node)
+
+ node.each_descendant(:send) do |send_node|
+ add_offense(send_node, :selector) if method_name(send_node) == :remove_index
+ end
+ end
+
+ def method_name(node)
+ node.children[1]
+ end
+ end
+ end
+ end
+end