From dcb1e8040a8fcbdf14f6ed6d7b4e28e7db050c06 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 2 Mar 2018 15:42:26 +0200 Subject: [PATCH] MySQL charset change improvements --- .../Crm/Resources/metadata/entityDefs/Account.json | 1 + application/Espo/Services/MysqlCharacter.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index bf2f2ff5fa..1da5af6d88 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -2,6 +2,7 @@ "fields": { "name": { "type": "varchar", + "maxLength": 249, "required": true, "trim": true }, diff --git a/application/Espo/Services/MysqlCharacter.php b/application/Espo/Services/MysqlCharacter.php index 97d7e2a16b..3a3904ca6b 100644 --- a/application/Espo/Services/MysqlCharacter.php +++ b/application/Espo/Services/MysqlCharacter.php @@ -54,6 +54,15 @@ class MysqlCharacter extends \Espo\Core\Services\Base $maxIndexLength = 1000; } + //Account name + $sth = $pdo->prepare("SELECT `name` FROM `account` WHERE LENGTH(name) > 249"); + $sth->execute(); + $row = $sth->fetch(\PDO::FETCH_ASSOC); + if (empty($row)) { + $sth = $pdo->prepare("ALTER TABLE `account` MODIFY `name` VARCHAR(249)"); + $sth->execute(); + } + $fieldListExceededIndexMaxLength = \Espo\Core\Utils\Database\Schema\Utils::getFieldListExceededIndexMaxLength($ormMeta, $maxIndexLength); foreach ($ormMeta as $entityName => $entityParams) {