Skip to content

Commit c5f50a8

Browse files
#13580: DB schema consistency fix.
1 parent 83371e1 commit c5f50a8

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Config\ConfigOptionsListConstants;
1717
use Magento\Framework\Config\Data\ConfigData;
1818
use Magento\Framework\Config\File\ConfigFilePool;
19+
use Magento\Framework\DB\Adapter\AdapterInterface;
1920
use Magento\Framework\DB\Adapter\Pdo\Mysql;
2021
use Magento\Framework\Exception\FileSystemException;
2122
use Magento\Framework\Filesystem;
@@ -603,7 +604,7 @@ private function setupModuleRegistry(SchemaSetupInterface $setup)
603604
*/
604605
private function setupCoreTables(SchemaSetupInterface $setup)
605606
{
606-
/* @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */
607+
/* @var $connection AdapterInterface */
607608
$connection = $setup->getConnection();
608609
$setup->startSetup();
609610

@@ -619,12 +620,12 @@ private function setupCoreTables(SchemaSetupInterface $setup)
619620
* Create table 'session'
620621
*
621622
* @param SchemaSetupInterface $setup
622-
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
623+
* @param AdapterInterface $connection
623624
* @return void
624625
*/
625626
private function setupSessionTable(
626627
SchemaSetupInterface $setup,
627-
\Magento\Framework\DB\Adapter\AdapterInterface $connection
628+
AdapterInterface $connection
628629
) {
629630
if (!$connection->isTableExists($setup->getTable('session'))) {
630631
$table = $connection->newTable(
@@ -658,12 +659,12 @@ private function setupSessionTable(
658659
* Create table 'cache'
659660
*
660661
* @param SchemaSetupInterface $setup
661-
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
662+
* @param AdapterInterface $connection
662663
* @return void
663664
*/
664665
private function setupCacheTable(
665666
SchemaSetupInterface $setup,
666-
\Magento\Framework\DB\Adapter\AdapterInterface $connection
667+
AdapterInterface $connection
667668
) {
668669
if (!$connection->isTableExists($setup->getTable('cache'))) {
669670
$table = $connection->newTable(
@@ -712,12 +713,12 @@ private function setupCacheTable(
712713
* Create table 'cache_tag'
713714
*
714715
* @param SchemaSetupInterface $setup
715-
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
716+
* @param AdapterInterface $connection
716717
* @return void
717718
*/
718719
private function setupCacheTagTable(
719720
SchemaSetupInterface $setup,
720-
\Magento\Framework\DB\Adapter\AdapterInterface $connection
721+
AdapterInterface $connection
721722
) {
722723
if (!$connection->isTableExists($setup->getTable('cache_tag'))) {
723724
$table = $connection->newTable(
@@ -748,12 +749,12 @@ private function setupCacheTagTable(
748749
* Create table 'flag'
749750
*
750751
* @param SchemaSetupInterface $setup
751-
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
752+
* @param AdapterInterface $connection
752753
* @return void
753754
*/
754755
private function setupFlagTable(
755756
SchemaSetupInterface $setup,
756-
\Magento\Framework\DB\Adapter\AdapterInterface $connection
757+
AdapterInterface $connection
757758
) {
758759
if (!$connection->isTableExists($setup->getTable('flag'))) {
759760
$table = $connection->newTable(
@@ -795,6 +796,8 @@ private function setupFlagTable(
795796
'Flag'
796797
);
797798
$connection->createTable($table);
799+
} else {
800+
$this->updateColumnType($connection, 'flag', 'flag_data', 'mediumtext');
798801
}
799802
}
800803

@@ -1548,4 +1551,28 @@ function ($value, $key) {
15481551

15491552
return !empty($adminData);
15501553
}
1554+
1555+
/**
1556+
* Update flag_data column data type to maintain consistency.
1557+
*
1558+
* @param AdapterInterface $connection
1559+
* @param string $tableName
1560+
* @param string $columnName
1561+
* @param string $typeName
1562+
*/
1563+
private function updateColumnType(
1564+
AdapterInterface $connection,
1565+
string $tableName,
1566+
string $columnName,
1567+
string $typeName
1568+
): void {
1569+
$tableDescription = $connection->describeTable($tableName);
1570+
if ($tableDescription[$columnName]['DATA_TYPE'] !== $typeName) {
1571+
$connection->modifyColumn(
1572+
$tableName,
1573+
$columnName,
1574+
$typeName
1575+
);
1576+
}
1577+
}
15511578
}

0 commit comments

Comments
 (0)