When you run rails db: migrate
I got the following error!
StandardError: An error has occurred, all later migrations canceled:
Translated literally, it means that all subsequent migrations were canceled due to an error.
In addition, I am getting this error.
Mysql2::Error: Specified key was too long; max key length is 767 bytes
This error seems to occur because the specified key is too long. The key length of max seems to be 767 bytes.
The key length is max 767 bytes, but it seems that an error has occurred because the key is too long.
For the 255-character VARCHER type generated by rails by default
◎ ** utf8mb4 is 4 bytes per character **, 255 x 4 bytes = 1020 bytes An error will occur because it will exceed 767 bytes.
Change the character code specification to ** utf8 **
◎ utf8 is 3 bytes per character, 255 x 3 bytes = 765 bytes
It fits almost exactly, so this is the solution!
database.yml
default: &default
encoding: utf8
Do bundle install
and reboot with rails s
!
afterwards,
$ rails db:migrate:reset
You have successfully migrated!
Recommended Posts