Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for separating associations into their own section in the annotation #137

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

carldr
Copy link

@carldr carldr commented Jul 13, 2024

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
Copy link
Author

carldr commented Jul 14, 2024

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

@drwl
Copy link
Owner

drwl commented Jul 15, 2024

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?

@carldr
Copy link
Author

carldr commented Jul 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants