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

Feature: further customization to achieve more compact annotations #150

Open
brandondrew opened this issue Sep 14, 2024 · 3 comments
Open

Comments

@brandondrew
Copy link

I would love to be able to customize a few more things about the annotations.

  1. Instead of adding another line for # Schema version: 20240510213625, what if it could be displayed as below?
  2. Since the table name normally is predictable based on the model name, and is already explicitly in the code when it diverges from the convention, it would be nice to be able to remove it and condense the annotations by 2 lines.
  3. It would be very useful if foreign keys could be added along with constraints & indices, instead of requiring an extra section below the column information.

So instead of this:

# == Schema Information
# Schema version: 20240510213625
#
# Table name: app_gem_versions
#
#  id                  :integer          not null, primary key
#  current_version     :string           not null
#  latest_version      :string           not null
#  newer_major_version :string
#  newer_minor_version :string
#  newer_patch_version :string
#  created_at          :datetime         not null
#  updated_at          :datetime         not null
#  app_gem_id          :integer          not null, indexed, foreign key
#  app_id              :integer          not null, indexed, foreign key
#
# Foreign Keys
#
#  app_gem_id  (app_gem_id => app_gems.id)
#  app_id      (app_id => apps.id)

it would be possible to have this:

# == Schema Information (20240510213625) ==
#
#  id                  :integer          not null, primary key
#  current_version     :string           not null
#  latest_version      :string           not null
#  newer_major_version :string
#  newer_minor_version :string
#  newer_patch_version :string
#  created_at          :datetime         not null
#  updated_at          :datetime         not null
#  app_gem_id          :integer          not null, indexed, foreign key
#  app_id              :integer          not null, indexed, foreign key

If any of these things are already possible, I wasn't able to figure out how to do them.

@drwl
Copy link
Owner

drwl commented Sep 16, 2024

@brandondrew hi there -- thanks for using the gem and adding an issue!

The things you're asking for make sense, although I'm not if it's currently possible to make it configurable as you'd want it. We'd need to add additional options, see [1] for an example, or add templating-esque functionality so we don't break the current existing behavior used by many. If you have any ideas there that would be great, or if you want to start on a PR, I'd be more than happy to assist there.

For the 3rd ask about separate foreign keys, just to clarify, is the first output (has , foreign key) taken from your Rails app?

[1] https://github.com/drwl/annotaterb/pull/50/files

@brandondrew
Copy link
Author

@drwl

Yes, this was output from a real Rails app that I have access to and was using AnnotateRB in, as a way to help me learn my way around:

# Foreign Keys
#
#  app_gem_id  (app_gem_id => app_gems.id)
#  app_id      (app_id => apps.id)

I'm not sure if that answers your question. I may not have understood what you were asking.

@brandondrew
Copy link
Author

Yes, I'd be open to considering opening a PR.

For starters I'm hacking the results I want by monkey-patching in my app with an initializer. Hopefully (if I find the time) that will work its way into my fork, and result in a PR. I've added the first two features so far through monkey-patching.

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

No branches or pull requests

2 participants