ctran / annotate_models

Annotate Rails classes with schema and routes info
Other
4.41k stars 598 forks source link

Allow composite foreign keys #1013

Closed carldr closed 3 months ago

carldr commented 6 months ago

I'm using composite foreign keys in my database, and currently Annotate complains with warnings like :

Unable to annotate app/models/monitor_base.rb: comparison of Array with Array failed
Unable to annotate app/models/monitor_base.rb: no implicit conversion of nil into Array

This pull request adds support for composite keys, with output such as :

#  fk_rails_...  ([id, default_notification_policy_id] => notification_policies.[team_id, id])
#  fk_rails_...  (owner_id => users.id)

(The PR also hacks around with Gemfile and spec/spec_helper.rb so I could get the tests to run locally on my Ruby version - those changes aren't really necessary.)