Seeing the warning in the admin page saying that my SQL configuration does not support 4-bytes utf8 characters, I followed the guide here: https://docs.nextcloud.com/server/15/admin_manual/configuration_database/mysql_4byte_support.html
And oh boy! that was a very bad idea!
The thing is, even official apps are not ready to do the conversion. For instance, the
oc_addressbooks table (which is, I guess, from the official Contacts app) has columns that are both
varchar(255) and this is very problematic.
I am on Ubuntu 18.04.2 LTS and, there, MySQL is configured to have a maximum of 767 bytes for unique keys. When in regular UTF-8,
varchar(255) actually takes 765 bytes (255*3), which is less than 767, so we’re good. But when converting to 4-bytes UTF-8 (utf8mb4), then these unique keys are now 1020 bytes long (255*4), which is more than the limit and that’s when the shit hits the fan.
I think there should be more tests done before advising to do the conversion, because the solution is not that simple, as explained here: https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes
Changing the max key length only works in specific conditions: the row format must be dynamic or compressed, and the InnoDB file format must be Barracuda.
I would advise to remove the warning from the NC admin panel.