-
Notifications
You must be signed in to change notification settings - Fork 120
Description
I'm using utf8mb4 as default charset of mysql. (utf8 is very popular setting in APAC region)
When I ran the latest migration of unread, I was caught by limitation of key length (767bytes)
Mysql2::Error: Specified key was too long; max key length is 767 bytes:
CREATE UNIQUE INDEX `read_marks_reader_readable_index` ON `read_marks` (`reader_id`, `reader_type`, `readable_type`, `readable_id`)
Because utf8 requires 3 or 4 times longer bytes than latin1, those columns are too large to create a unique index.
I think there are 2 solutions.
One is adding CHARSET option to create statement.
create_table ReadMark, :options => 'DEFAULT CHARSET=latin1' ...
This ignores default charset of database.
Actually I don't use multibyte characters for readable_type and reader_type, so this makes no problem.
But for someone using multibyte characters for readable_type and reader_type, it may be a breaking change.
Another one is shortening readable_type and reader_type. This is more breaking change.
change_column ReadMark, :readable_type, :string, :limit=>100
change_column ReadMark, :reader_type, :string, :limit=>100
I prefere former one, so can I make PR to add charset option?