[Ruby] docker rails db:migrateにてエラー(StandardError: An error has occurred, all later migrations canceled:)

less than 1 minute read

This is Qiita’s first post. Thank you.


  • image: mysql:5.7
  • FROM ruby: 2.6.3
  • Rails


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

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


Although it was not completely specified, it is possible that the previous migration process was not successful. There was an error around creating the table. The error Mysql should have been fixed…


Reset the database.

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

Migration again

$ docker-compose exec web rails db:migrate

Now it’s repaired. For confirmation, I think it’s good to see if the DB is working properly from the console.