ceresfairfood / fairfood-install

Ansible scripts to install Ceres Fair Food on a server
0 stars 0 forks source link

Create database with Mysql's `utf8` #9

Closed mkllnk closed 4 years ago

mkllnk commented 6 years ago

We create the database manually and it comes with the defaults of the system. Currently Debian's Mariadb default charset is utf8mb4, the full utf8 supporting emojis etc. The bigger charset can cause hitting limits on indexes:

Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `index_user_flags_on_user_id_and_name` ON `user_flags` (`user_id`, `name`)

Enabling a higher index length limit needs a few changes to the database configuration and each table. Defining the charset for each table would be a bit hacky with Rails. So until we completely migrate to utf8mb4, we need to create the database with utf8 as default or new tables introduced by migrations will have the wrong charset. This is the same behaviour as rake db:create which seems to set utf8 as default charset for the database.

mkllnk commented 4 years ago

It looks like newer Debian versions set utf8mb4 by default.