diff --git a/application/Espo/Core/Utils/Database/DBAL/Platforms/MySqlPlatform.php b/application/Espo/Core/Utils/Database/DBAL/Platforms/MySqlPlatform.php index 19dc3609ba..de81cfc6b9 100644 --- a/application/Espo/Core/Utils/Database/DBAL/Platforms/MySqlPlatform.php +++ b/application/Espo/Core/Utils/Database/DBAL/Platforms/MySqlPlatform.php @@ -379,14 +379,14 @@ class MySqlPlatform extends \Doctrine\DBAL\Platforms\MySqlPlatform // Charset if ( ! isset($options['charset'])) { - $options['charset'] = 'utf8'; + $options['charset'] = 'utf8mb4'; } $tableOptions[] = sprintf('DEFAULT CHARACTER SET %s', $options['charset']); // Collate if ( ! isset($options['collate'])) { - $options['collate'] = 'utf8_unicode_ci'; + $options['collate'] = 'utf8mb4_unicode_ci'; } $tableOptions[] = sprintf('COLLATE %s', $options['collate']); @@ -465,4 +465,4 @@ class MySqlPlatform extends \Doctrine\DBAL\Platforms\MySqlPlatform return implode(', ', $queryFields); } //end: ESPO -} \ No newline at end of file +} diff --git a/application/Espo/Core/Utils/Database/Schema/Converter.php b/application/Espo/Core/Utils/Database/Schema/Converter.php index fab2518663..dfa2d65739 100644 --- a/application/Espo/Core/Utils/Database/Schema/Converter.php +++ b/application/Espo/Core/Utils/Database/Schema/Converter.php @@ -373,6 +373,13 @@ class Converter } } + $databaseParams = $this->getConfig()->get('database'); + if (!isset($databaseParams['charset']) || $databaseParams['charset'] == 'utf8mb4') { + $dbFieldParams['platformOptions'] = array( + 'collation' => 'utf8mb4_unicode_ci', + ); + } + switch ($fieldParams['type']) { case 'id': case 'foreignId': @@ -515,4 +522,4 @@ class Converter return $tables; } -} \ No newline at end of file +}