blob: b7c3705bde9d8c6451ac44129c7c53bd7ab16313 (
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
|
# frozen_string_literal: true
module Gitlab
module Database
module SchemaValidation
class Indexes
def initialize(structure_sql, database)
@structure_sql = structure_sql
@database = database
end
def missing_indexes
structure_sql.indexes.map(&:name) - database.indexes.map(&:name)
end
def extra_indexes
database.indexes.map(&:name) - structure_sql.indexes.map(&:name)
end
def wrong_indexes
structure_sql.indexes.filter_map do |structure_sql_index|
database_index = database.fetch_index_by_name(structure_sql_index.name)
next if database_index.nil?
next if database_index.statement == structure_sql_index.statement
structure_sql_index.name
end
end
private
attr_reader :structure_sql, :database
end
end
end
end
|