Thursday, March 9, 2017

Laravel 5.4 upgrade, converting to utf4mb from utf8

I'm busy upgrading one of my sites to Laravel 5.4 from 5.3. I noticed when going through the current Github repository that the default character set and collation has been changed from utf8 to utf8mb4 in order to provide support for emojis.

My current database (MariaDB 10.0.29) is currently set to use utf8 but I would however like to upgrade it to use utf8mb4. Unfortunately, I haven't been able to find any documentation regarding this process.

Perhaps I'm overthinking it, but I would have thought that changing the character set and collation of a database would require some work, at very least running some ALTER TABLE commands.

  • Is it necessary to go change the character set and collation on the database and tables? Or would it suffice to simply change the settings in my config/database.php file?
  • If so, would anyone be able to provide an example migration (Or some MySQL code) on how to achieve this, bearing in mind that preserving existing data is essential.

Thanks



via Jonathon

Advertisement