directus / v8-archive

Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
https://docs.directus.io/api/reference.html
507 stars 203 forks source link

Older MySQL/MariaDB Index Issue #2084

Open volomike opened 4 years ago

volomike commented 4 years ago

On v8.8.1 of Directus, on many shared hosting plans, some of their older servers have an older MySQL version that doesn't like the idx_user_collection_tree index on the directus_collection_presets table. It errors out on the install because it has a max index size of like 787 bytes I think I saw? Other users may encounter this same problem on any host with an older version of MySQL or MariaDB.

The fix:

  1. I had to install a duplicate system on my local workstation with everything named the same as it would have been on the server, and then login at least once into the admin system. On the naming, that included exact database names and exact database user names.

  2. I then copied up all the files to the hosting plan server, including the custom ones in the config folder.

  3. From there, on my local server, using phpMyAdmin, I removed the index idx_user_collection_tree from directus_collection_presets. Then, I changed the collation on the directus_collection_presets.title to utf8_general_ci instead of the heavier utf8mb4_general_ci. Yeah, I might have troubles with some international UTF-8 characters (like for China), but it will work for most English and European languages, and perhaps a few others. Next, recreate the idx_user_collection_tree unique index on those 3 columns and you won't get the index size issue. I then did a database export from my local server and then imported into the new server.

  4. Last, just edit the config/{your-site-name}.php file and ensure pathing is correct between the differences of your local web server and the remote shared hosting web server.

  5. At that point, I could login on the admin system of the new server and all was well.

volomike commented 4 years ago

Nope. I tried the above and it almost worked. I get stuck trying to create a new field on a collection. Same error -- the 787 bytes on the index issue. You see that error when going to Javascript console. I tried thinking up a fix but nothing worked.