annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Allow for separating associations into their own section in the annotation

Open carldr opened this issue 1 year ago • 3 comments

Adds a --separate-associations option which puts associations into their own section. This allows for easier eyeballing of associations in the table, even more so than --classified-sort. Tests and updated README included.

Produces output like :

# == Schema Information
#
# Table name: team_users
#
#  id         :bigint           not null, primary key
#  roles      :jsonb            not null
#  created_at :datetime         not null
#  updated_at :datetime         not null
#
# Associations
#
#  team_id    :bigint           not null
#  user_id    :bigint           not null
#
# Indexes
#
#  index_team_users_on_team_id  (team_id)
#  index_team_users_on_user_id  (user_id)
#
# Foreign Keys
#
#  fk_rails_6a8dc6a6fc  (team_id => teams.id)
#  fk_rails_8b0a3daf0d  (user_id => users.id)
#

The pull request also includes a change to add a period between the table name and composite keys. Previously it would produce :

#  fk_rails_da54bff5b7  ([team_id, cheese_id] => cheeses[team_id, id])

And now :

#  fk_rails_da54bff5b7  ([team_id, cheese_id] => cheeses.[team_id, id])

which better matches the formatting of non-composite keys.

And lastly, a change to gemspec which allows the Gem to be used locally with bundle config set local.annotaterb <local-path> inside a Rails app, which avoids the need to commit and push inside annotaterb, then bundle update in the Rails app, so see how changes affect real-world output.

carldr avatar Jul 13 '24 12:07 carldr

Added a commit to fix some style issues, I'd missed the standardrb step.

carldr avatar Jul 14 '24 08:07 carldr

Hi @carldr, thanks so much for submitting a PR. I think the changes make sense to me, I'm going to spend a bit more time thinking through the separate associations bit.

Would you mind splitting up the changes into separate PRs so that it's easier for any future person to parse the changes? Specifically, the separate associations change, changes to gemspec, and the change to composite foreign keys?

drwl avatar Jul 15 '24 21:07 drwl

Would you mind splitting up the changes into separate PRs so that it's easier for any future person to parse the changes? Specifically, the separate associations change, changes to gemspec, and the change to composite foreign keys?

Yeah, will do, give me a day or two to do that.

carldr avatar Jul 17 '24 19:07 carldr

I'm doing a clean up of the project PRs and issues. Closing this for now as it's a bit stale. Feel free to re-open if/when you get around to this. Happy to help on the review side.

drwl avatar Mar 31 '25 21:03 drwl