LoginSignup
0
0

More than 3 years have passed since last update.

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

Posted at

Qiita初投稿となります。よろしくお願いします。

環境

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

エラー

docker環境で構築したrailsにて、docker-compose exec web rails db:migrateとしたところ、以下エラー

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
....以下省略

原因

完全な特定には至らなかったが、以前行ったマイグレーションの処理がうまくいっていない可能性がある。テーブル作成周りでエラーが出ていた。
エラーのMysqlに関しては修正しているはず・・・。

解決方法

データベースのリセットを行う。

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

再度マイグレーション

$ docker-compose exec web rails db:migrate

これで修復できました。確認の為、コンソールから正しくDB周りが動いてるか見るといいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0