[Awesome Ruby Gem] Use migration_comments gem to comment your Rails Migration
migration_comments
Using MigrationComments, you can simply add comments during your migrations. Or if you already have existing data structures, just add the comments afterwards in a separate migration. And of course you can always modify and delete these comments in later migrations.
So where are these comments used? Firstly, they will be included in your schema.rb dump which is where your IDE (e.g. RubyMine, VS Code) should be learning about your model structure. This means that they’ll be available at any point in your project. Additionally, if you are using the 'annotate’ gem, these comments will be added to the annotations that are generated within your model.rb file.
Installation
You can install it as a gem:
1 | gem install migration_comments |
or add it into a Gemfile (Bundler):
1 | # Gemfile |
Then, run bundle install
.
1 | bundle install |
Usage
To add a comment to an existing structure…
1 | def self.up |
Or you can use the change_table macro…
1 | def self.up |
Creating a new table?
1 | def self.up |
Annotate (aka AnnotateModels)
The Annotate (aka AnnotateModels) gem annotating Rails classes with schema and routes info by adding a comment summarizing the current schema to the top or bottom of each of your codes.
The schema comment looks like this:
1 | # == Schema Info |