mysql utf8mb4: Specified key was too long; max key length is 767 bytes

Specified key was too long; max key length is 767 bytes

That error means you are trying to add unique index on a varchar(255) utf8mb4 column. In utf8mb4 column, each character needs 4 bytes. So 255 characters means 1020 bytes. The max key length is 767 bytes.

Option1:

Do you really need 255 characters?..if not reduce it.

change_column :attachments, :message_uuid, :string, :limit => 38

Option2:

If you really need all 255 characters, consider using this innodb setting.

http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_large_prefix