I’m developing scripted Concrete installation for our agency’s purposes and would like to apply the database collation of utf8mb4_swedish_ci from the get-go, or whatever the user chooses in a settings file.
I’ve tried calling concrete/bin/concrete c5:database:charset:set utf8mb4_swedish_ci immediately after my c5:install command is done, but this leaves several table collations as utf8mb4_unicode_ci as already created foreign keys can’t be modified by the command after creation.
I’ve also tried calling c5:config set database.connections.concrete.collation utf8mb4_swedish_ci prior to c5:install and this creates a promising looking install.database.php in my application/config directory and concrete c5:config get database.connections.concrete.collation returns my value just fine but this doesn’t alter the installation process. The installer still reports
Database should support the configured character set and collation… passed (The database supports the “utf8mb4” character set and the “utf8mb4_unicode_ci” collation.).
The installer code looks like it’s trying to retrieve these values from somewhere and patching in the desired collation value string to where I figured it would work, the installer hangs before outputting the above message instead. (After exiting the installer with Ctrl+C at this point I also noticed the tables tmp_checkCollationFieldLength0 and tmp_checkCollationFieldLength1 in my database.)
So, is what I’m trying to achieve even possible and if so, what would be the right way to go about it?
A few times when I’ve been trying to update a site, and as part of that process change the character set and collation, I’ve hit issues with the foreign keys not wanting to update.
To fix, what I would do is export the database in full, open up the SQL in a text editor, and do a find and replace on the character set and encoding flags on the tables and save that down. Then I’d import that to an empty database and update my database config to point at the new database, setting a matching character set.
But this idea doesn’t really help you directly with what you’re describing - that sounds like a bug with the c5:database:charset:set function. It’s a bit awkward to have to script up the above as a workaround, but I thought I’d post anyway in case it gives you an idea.
If you want to configure the collation (which implies the charset) to be used in the database before installing Concrete, you can create the file application/config/database.php with some content like this:
Please remark that the collation you choose should be supported by your MySQL/MariaDB instance.
You can list the supported collations by running this SQL query: