Class: Migflow::Analyzers::Rules::MissingForeignKeyRule

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

Constant Summary collapse

FOREIGN_KEY_PATTERN =
/foreign_key.*references/

Instance Method Summary collapse

Instance Method Details

#call(tables) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/migflow/analyzers/rules/missing_foreign_key_rule.rb', line 9

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