Error in docker rails db: migrate (StandardError: An error has occurred, all later migrations canceled :)

This is Qiita's first post. Thank you.

environment

error

In rails built in docker environment, when docker-compose exec web rails db: migrate is set, the following error occurs

rails aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Invalid use of NULL value: ALTER TABLE `tasks` CHANGE `name` `name` varchar(255) NOT NULL
....Omitted below

Cause

It wasn't completely identified, but it's possible that the previous migration process wasn't working. There was an error around creating the table. I should have fixed the error Mysql ...

Solution

Reset the database.

$ docker-compose exec web rails db:migrate:reset

Migrate again

$ docker-compose exec web rails db:migrate

I was able to repair it. For confirmation, I think you should see if the DB surroundings are working correctly from the console.

Recommended Posts

Error in docker rails db: migrate (StandardError: An error has occurred, all later migrations canceled :)
What to do when an error occurs in rails db: migrate ((StandardError: An error has occurred, this and all later migrations canceled :))
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
[Rails] Error StandardError: An error has occurred, all later migrations canceled: Column `Foreign key name` on table` Table name` does not match column ʻid` on `Table name`
Error in rails db: migrate
[Docker] The story that an error occurred in docker-compose up
About the error that occurred when adding the column name in rails (rails db: migrate, rails db: rollback, add)
After all, what is [rails db: migrate] doing?
Migration error after Activerecord association in Rails5 + Docker environment (2)
[Rails] "private method` String' called ~ "error when db: migrate
Migration error after Activerecord association in Rails5 + Docker environment
Autoprefixer does n’t support Node v4.8.2. Update it. Error that occurred in Rails [Docker Rails5 Bootstrap]