Class: Migflow::Analyzers::Rules::MissingIndexRule

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/migflow/analyzers/rules/missing_index_rule.rb

Instance Method Summary collapse

Instance Method Details

#call(tables) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/migflow/analyzers/rules/missing_index_rule.rb', line 7

def call(tables)
  tables.flat_map do |table_name, table|
    foreign_key_columns(table).reject { |col| indexed?(col, table) }.map do |col|
      warning(
        table: table_name,
        column: col[:name],
        message: "Column '#{col[:name]}' looks like a foreign key but has no index",
        severity: :warning
      )
    end
  end
end