paper_trail: Unknown collation: 'utf8mb4_col'
Setting up a Rails 5.0.0.beta3 app with paper_trail pointing to master. I’m deploying to an AWS RDS MySQL instance. Deploying fails when trying to migrate the DB with the following error:
Mysql2::Error: Unknown collation: 'utf8mb4_col': CREATE TABLE `versions` (`id` int AUTO_INCREMENT PRIMARY KEY, `item_type` varchar(255) NOT NULL, `item_id` int NOT NULL, `event` varchar(255) NOT NULL, `whodunnit` varchar(255), `object` longtext, `created_at` datetime) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_col
I was able to get the table created by changing the collation to “utf8mb4_unicode_ci” (recommened in the blog post that’s linked to from the paper_trail-generated migration file: https://mathiasbynens.be/notes/mysql-utf8mb4)
However, once the table was created I then got another error:
Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE INDEX `index_versions_on_item_type_and_item_id` ON `versions` (`item_type`, `item_id`)
This is a lot less than the 191 characters you should be able to use for an index in InnoDB with utf8mb4 columns. Even when I manually shortened the name down to “type_item_id” it still complained about it being too long.
This database was originally created with utf8/utf8_general_ci and then modified to utf8mb4. Maybe that has something to do with it? I can do further testing (drop DB and re-create with different encoding/collation) if needed, just let me know!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- Set MySQL collation: versions tbl: utf8mb4_general_ci Should fix the "Unknown collation: 'utf8mb4_col'" error from https://github.com/airblade/paper_trail/issues/741 — committed to paper-trail-gem/paper_trail by jaredbeck 8 years ago
- Set MySQL collation: versions tbl: utf8mb4_general_ci Should fix the "Unknown collation: 'utf8mb4_col'" error from https://github.com/airblade/paper_trail/issues/741 — committed to paper-trail-gem/paper_trail by jaredbeck 8 years ago
Yup that’s the one! Now if you change that collation lets see if you get the same key length error…