annotate_models icon indicating copy to clipboard operation
annotate_models copied to clipboard

Yard doc style annotations do not update after migrations

Open tmr08c opened this issue 5 years ago • 0 comments

After generating annotations using the Yard doc format, running migrations does not update the annotations.

Commands

bundle exec annotate --models -f yard

Generates:

# == Schema Information
#
# Table name: users
#
# @!attribute id
#   @return []
# @!attribute name
#   @return [String]
# @!attribute created_at
#   @return [Time]
# @!attribute updated_at
#   @return [Time]
#
class User < ApplicationRecord
end

Generate a new migration and migrate:

> rails g migration add_email_to_users email:string
> rails db:migrate
== 20200322114415 AddEmailToUsers: migrating ==================================
-- add_column(:users, :email, :string)
   -> 0.0019s
== 20200322114415 AddEmailToUsers: migrated (0.0020s) =========================

Manually run annotations, but annotations are not updated:

› bundle exec annotate --models -f yard        
Model files unchanged.

Version

  • annotate version: 3.1.1
  • rails version: 6.0.2.2
  • ruby version: 2.6.5

Notes

I believe the source of the problem is the regular expression used to extract columns from the annotation blob:

https://github.com/ctran/annotate_models/blob/111640d077836ced23cfffb882c93e40968ab9d9/lib/annotate/annotate_models.rb#L510

tmr08c avatar Mar 22 '20 12:03 tmr08c