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

different_definition_foreign_keys.rb « validators « schema_validation « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8969fa76cd8a4932b005f7df6b4512b9b2dfb09d (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
# frozen_string_literal: true

module Gitlab
  module Database
    module SchemaValidation
      module Validators
        class DifferentDefinitionForeignKeys < BaseValidator
          ERROR_MESSAGE = "The %s foreign key has a different statement between structure.sql and database"

          def execute
            structure_sql.foreign_keys.filter_map do |structure_sql_fk|
              database_fk = database.fetch_foreign_key_by_name(structure_sql_fk.name)

              next if database_fk.nil?
              next if database_fk.statement == structure_sql_fk.statement

              build_inconsistency(self.class, structure_sql_fk, database_fk)
            end
          end
        end
      end
    end
  end
end