mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-03 16:04:30 +00:00
37 lines
823 B
Ruby
37 lines
823 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Schema
|
|
module Validation
|
|
module Fixers
|
|
def self.create_for(inconsistency)
|
|
case inconsistency.type
|
|
when 'Gitlab::Schema::Validation::Validators::MissingIndexes'
|
|
MissingIndex.new(inconsistency)
|
|
else
|
|
Base.new(inconsistency)
|
|
end
|
|
end
|
|
|
|
class Base
|
|
attr_reader :table_name
|
|
|
|
def initialize(inconsistency)
|
|
data = inconsistency.to_h
|
|
@table_name = data[:table_name]
|
|
@structure_sql_statement = data[:structure_sql_statement]
|
|
end
|
|
|
|
def statement
|
|
structure_sql_statement&.chomp
|
|
end
|
|
|
|
private
|
|
|
|
attr_reader :structure_sql_statement
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|