Welcome to mirror list, hosted at ThFree Co, Russian Federation.

remove_index.rb « migration « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26d271207dcb0d23d631ba483b19a8856683ca43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

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::Base
        include MigrationHelpers

        MSG = '`remove_index` requires downtime, use `remove_concurrent_index` instead'

        def on_def(node)
          return unless in_migration?(node)

          node.each_descendant(:send) do |send_node|
            add_offense(send_node.loc.selector) if method_name(send_node) == :remove_index
          end
        end

        def method_name(node)
          node.children[1]
        end
      end
    end
  end
end