debian-mirror-gitlab/rubocop/cop/migration/remove_index.rb

29 lines
715 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
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|
2018-03-17 18:26:18 +05:30
add_offense(send_node, location: :selector) if method_name(send_node) == :remove_index
2017-08-17 22:00:37 +05:30
end
end
def method_name(node)
node.children[1]
end
end
end
end
end