[Rails] Annotate is not executed when migrating

Introduction

I've summarized what I tried when Annotate couldn't be executed and the comment wasn't written out.

environment

What is Annotate?

It is a gem that comments the information written in the schema to the beginning of the file with the routing information. You can save the trouble of checking column information and routing. For the introduction and detailed usage, refer to the following. [Rails] How to use annotation

Bug that occurred (comments are not written when migrating)

Annotate was executed during migration, and even though it was set to be commented on model, there was a problem that it was not executed. When I created the first migration file in the working branch and migrated, the comment was written out, but when I created the second migration file in the working branch and migrated, the comment was written out. did not.

I tried various things, but in the end I deleted the comment once and then migrated it, and it worked.

What i did

1. Check the configuration file

Check the Annotate setting in lib / tasks / auto_annotate_models.rake generated by $ bundle exec rails g annotate: install.

auto_annotate_models.rake


'skip_on_db_migrate' => 'false', 

Since it is false, it is set to write comments at the time of migrate. (No problem here)

2. Manually run Annotate

Since it is not executed at the time of migarate, execute Annotate manually. The comment is still not written out. ..

.bash


$ bundle exec annoatate --models

3. Reinstall gem

If the comment is still not written, re-install the gem. In some cases, it was fixed by reinstalling.

4. Delete the comment of annotate

In my case, the comment was not written out after trying various things, so I decided to delete the comment.

.bash


$ bundle exec annotate --delete

Confirm that the comment has been deleted from the model, and execute it by migrate or manually.

.bash


$ bundle exec rails db:migrate

or

$ bundle exec annoatate --models

When I deleted it and migrated it, it was exported to all models.

in conclusion

After all, I didn't understand why annotate wasn't executed during migration, but for the time being, a comment was written out. If anyone knows the cause, I would appreciate it if you could comment.

Recommended Posts

[Rails] Annotate is not executed when migrating
Rails must be exist error (@save is not executed)
[Rails] fields_for is not displayed
[Rails] When the layout change of devise is not reflected
rails AWS deployment is not reflected
Data is not registered in Rails.
MySQL is not running stably ... Rails app is not running.
[Rails] [Memo] When to add = to <%%> and when not
When UITextView is not displayed (Swift, Xcode)
When nginx conf is not reflected well in AWS Elastic Beanstalk + Rails environment
rails new app is not created with app name
When the project is not displayed in eclipse
Ebean.update () is not executed in the inherited model.
[Railways] Railways does not work when the RubyMine project root is other than the Rails root directory.
[Ruby on rails] When executing the heroku command, bash: heroku: command not found is displayed. [Rails tutorial]
When Spring Batch is executed continuously in Oracle, ORA-08177
When the server does not start with rails s
Fixed the phenomenon that vuetify built in Rails is not loaded when page transition is done
Rails is Owakon www
How to solve the problem when the value is not sent when the form is disabled in rails and sent
Yarn is not installed
[Rails] Record when the event did not fire when the javascript file name is the same as the controller
When I run rails: db: migrate, I get "Directly inheriting from ActiveRecord :: Migration is not supported."
How to automatically generate ER diagram when migrating with Rails6
The story when the test folder was not created in Rails
[Ruby on Rails] When parameter id acquisition does not work
When an error occurs even though validation is not set
[Rails DM] Let's create a notification function when DM is sent!
What to check when rails db: migration does not pass
The idea of cutting off when the error is not resolved
% rails db: When creating, the LoadError caused by mimemagic is
When [command not found: composer] is displayed when [composer install] is displayed in Laravel
Docker does not work when DOCKER_HOST is specified in WSL2
[Rails 6] jQuery introduction ・ uncaught reference error $ is not defined Error solution
Exit code 1 occurs when Rails is stopped in Docker environment
Behavior when each is executed in the reverse order Range
Logback log is not output when the server application is closed
What to do if the app is not created with the latest Rails version installed when rails new