debian-mirror-gitlab/lib/gitlab/database/schema_validation/structure_sql.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
793 B
Ruby
Raw Normal View History

2023-04-23 21:23:45 +05:30
# frozen_string_literal: true
module Gitlab
module Database
module SchemaValidation
class StructureSql
def initialize(structure_file_path)
@structure_file_path = structure_file_path
end
def indexes
@indexes ||= index_statements.map do |index_statement|
index_statement.relation.schemaname = "public" if index_statement.relation.schemaname == ''
Index.new(index_statement)
end
end
private
attr_reader :structure_file_path
def index_statements
parsed_structure_file.tree.stmts.filter_map { |s| s.stmt.index_stmt }
end
def parsed_structure_file
PgQuery.parse(File.read(structure_file_path))
end
end
end
end
end