Sha256: 508cea51b439ec560f50c110c4325e3628a4eac8eb4e0dd460af6163b2cef5c9

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

require_relative '../../migration_helpers'

module Gitlab
  module Styles
    module Rubocop
      module Cop
        module Migration
          # Cop that checks if `add_concurrent_foreign_key` is used instead of
          # `add_foreign_key`.
          class AddConcurrentForeignKey < RuboCop::Cop::Cop
            include MigrationHelpers

            MSG = '`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead'.freeze

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

              name = node.children[1]

              add_offense(node, :selector) if name == :add_foreign_key
            end

            def method_name(node)
              node.children.first
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gitlab-styles-1.0.0 lib/gitlab/styles/rubocop/cop/migration/add_concurrent_foreign_key.rb
gitlab-styles-0.1.0 lib/gitlab/styles/rubocop/cop/migration/add_concurrent_foreign_key.rb