From 65368519c76e505c0d2df79e90aebe902ecbfe09 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Thu, 20 Dec 2018 17:10:42 +0200 Subject: [PATCH] DBAL: compare text length --- .../Core/Utils/Database/DBAL/Schema/Comparator.php | 12 ++++++++++-- .../Utils/Database/Schema/tables/preferences.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/application/Espo/Core/Utils/Database/DBAL/Schema/Comparator.php b/application/Espo/Core/Utils/Database/DBAL/Schema/Comparator.php index 19351ff148..76ea2bc5fc 100644 --- a/application/Espo/Core/Utils/Database/DBAL/Schema/Comparator.php +++ b/application/Espo/Core/Utils/Database/DBAL/Schema/Comparator.php @@ -28,12 +28,11 @@ ************************************************************************/ namespace Espo\Core\Utils\Database\DBAL\Schema; -use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\Column; class Comparator extends \Doctrine\DBAL\Schema\Comparator { - public function diffColumn(Column $column1, Column $column2) { $changedProperties = array(); @@ -80,6 +79,15 @@ class Comparator extends \Doctrine\DBAL\Schema\Comparator } } + if ($column1->getType() instanceof \Doctrine\DBAL\Types\TextType) { + $length1 = $column1->getLength() ?: 16777215/* mediumtext length*/; + $length2 = $column2->getLength() ?: 16777215; + + if ($length2 > $length1) { + $changedProperties[] = 'length'; + } + } + if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) { if (($column1->getPrecision()?:10) != ($column2->getPrecision()?:10)) { $changedProperties[] = 'precision'; diff --git a/application/Espo/Core/Utils/Database/Schema/tables/preferences.php b/application/Espo/Core/Utils/Database/Schema/tables/preferences.php index 79c51029b3..3c07039620 100644 --- a/application/Espo/Core/Utils/Database/Schema/tables/preferences.php +++ b/application/Espo/Core/Utils/Database/Schema/tables/preferences.php @@ -47,7 +47,7 @@ return [ ], 'data' => [ 'type' => 'text', - 'dbType' => 'longtext', + 'len' => 16777216, ] ] ],