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

base.rb « validators « validation « schema « gitlab « lib « gitlab-schema-validation « gems - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 151af4b61e63621d369230a25af134137c296ca0 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

module Gitlab
  module Schema
    module Validation
      module Validators
        class Base
          ERROR_MESSAGE = 'A schema inconsistency has been found'

          def initialize(structure_sql, database)
            @structure_sql = structure_sql
            @database = database
          end

          def self.all_validators
            [
              ExtraTables,
              ExtraTableColumns,
              ExtraIndexes,
              ExtraTriggers,
              ExtraForeignKeys,
              MissingTables,
              MissingTableColumns,
              MissingIndexes,
              MissingTriggers,
              MissingForeignKeys,
              DifferentDefinitionTables,
              DifferentDefinitionIndexes,
              DifferentDefinitionTriggers,
              DifferentDefinitionForeignKeys
            ]
          end

          def execute
            raise NoMethodError, "subclasses of #{self.class.name} must implement #{__method__}"
          end

          private

          attr_reader :structure_sql, :database

          def build_inconsistency(validator_class, structure_sql_object, database_object)
            Inconsistency.new(validator_class, structure_sql_object, database_object)
          end
        end
      end
    end
  end
end