ctran/annotate_models

[Feature request] Place column comments at the end of the line

Epigene opened this issue · 3 comments

Hi, kudos for maintaining a most useful gem.

My problem is that column comments from Rails migrations are being placed in brackets just after column name, needlessly pushing everything else far to the right.

What is happening

In migration I have this

add_column(
 :rfps, :options, :jsonb,
  null: false, default: {},
  comment: "Unified place for event options, suff like :public, *_flag, etc.",
)

Then annotation is something like this:

# == Schema Information
#
# Table name: rfps
#
#  id                                                                        :bigint           not null, primary key
#  deleted_at                                                                :datetime         indexed => [currency_id, bid_submission_deadline, state], indexed => [currency_id], indexed
#  options(Unified place for event options, suff like :public, *_flag, etc.) :jsonb            default({}), not null

What would be better

Putting the comment at the end of the line would produce less whitespace in the middle of lines:

# == Schema Information
#
# Table name: rfps
#
#  id         :bigint    not null, primary key
#  deleted_at :datetime  indexed => [currency_id, bid_submission_deadline, state], indexed => [currency_id]
#  options    :jsonb     default({}), not null, comment => "Unified place for event options, suff like :public, *_flag, etc."

Version

  • annotate version 3.2.0
  • rails version 6.0.4.8
  • ruby version 2.7.5
ctran commented

This make sense and the best way to get what you want is to submit a PR.

On it, since I want that for quite some time now for all projects we're working on at the company. And I finally have some capacity for a PR 🥳

A PR was open to fix that. I don't know if we prefer to re-open this issue – I do not have permission to do so – of if just linking to it from the PR is enough. Just letting you know. :-)