Class: RailsLens::Analyzers::ForeignKeyAnalyzer
- Defined in:
- lib/rails_lens/analyzers/foreign_key_analyzer.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods included from ErrorHandling
Constructor Details
This class inherits a constructor from RailsLens::Analyzers::Base
Instance Method Details
#analyze ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rails_lens/analyzers/foreign_key_analyzer.rb', line 6 def analyze return [] unless connection.supports_foreign_keys? notes = [] existing_foreign_keys = connection.foreign_keys(table_name) belongs_to_associations.each do |association| next if association.polymorphic? foreign_key = association.foreign_key referenced_table = association.klass.table_name unless foreign_key_exists?(foreign_key, referenced_table, existing_foreign_keys) notes << NoteCodes.note(foreign_key, NoteCodes::FK_CONSTRAINT) end end notes end |