We have a complex legacy schema with a lot of tables and models, and I
can’t keep all of the paths between tables in my head, so just wrote
something that could help find the path between any two models just by
entering their model names like:
bundle exec modelist paths my_model_1 my_model_2
which results in (greatly simplified because a full actual response is
much, much longer):
checking for path from foobar to barfoo…
++++++±±+±-±-----
Paths from foobar to barfoo (2):
foobar.foo → foo.barfoos → barfoo
foobar.barfoo → barfoo
(shortest path last)
and:
bundle exec modelist search partial_search_string
results in:
Models:
Foo (table: foos)
Foobar (table: foobars)
Associations:
Bar (table: bars), association: foo (macro: belongs_to, options: {})
Loo (table: loos), association: f_users (macro: has_one, options:
{:foreign_key=>:foo_id})
Check it out and please report issues in github and do PR’s for fixes:
It is a little messy at the moment, but it seems to be working ok for
me,
unless I’m missing something.
Gary