Skip to content

Commit c8a3542

Browse files
committed
AC-11995:Add compatibility with MySQL 8.4 LTS for Magento CE
1 parent dbc6524 commit c8a3542

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

dev/tests/integration/tmp/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,16 @@ public function installSchema(array $request)
910910
$this->assertDbAccessible();
911911
$setup = $this->setupFactory->create($this->context->getResources());
912912
$this->setupModuleRegistry($setup);
913+
914+
$this->disableRestrictFKOnNonStandardKey($setup);
915+
913916
$this->setupCoreTables($setup);
914917
$this->cleanMemoryTables($setup);
915918
$this->log->logMeta('Schema creation/updates:');
916919
$this->declarativeInstallSchema($request);
920+
921+
$this->revertRestrictFKOnNonStandardKey($setup);
922+
917923
$this->handleDBSchemaData($setup, 'schema', $request);
918924
/** @var Mysql $adapter */
919925
$adapter = $setup->getConnection();
@@ -1827,4 +1833,31 @@ private function setIndexerModeSchedule(): void
18271833
$this->log->log(__("We couldn't change indexer(s)' mode because of an error: ".$e->getMessage()));
18281834
}
18291835
}
1836+
1837+
/***
1838+
* use of non-unique or partial keys as foreign keys is deprecated in MySQL8.4
1839+
*
1840+
* @param $setup
1841+
* @return void
1842+
*/
1843+
private function disableRestrictFKOnNonStandardKey($setup): void
1844+
{
1845+
$setup->getConnection()->query("
1846+
SET @OLD_RESTRICT_FK_ON_NON_STANDARD_KEY=@@GLOBAL.RESTRICT_FK_ON_NON_STANDARD_KEY,
1847+
@@GLOBAL.RESTRICT_FK_ON_NON_STANDARD_KEY=0
1848+
");
1849+
}
1850+
1851+
/***
1852+
* revert RESTRICT_FK_ON_NON_STANDARD_KEY to previous saved db value
1853+
*
1854+
* @param $setup
1855+
* @return void
1856+
*/
1857+
private function revertRestrictFKOnNonStandardKey($setup): void
1858+
{
1859+
$setup->getConnection()->query("
1860+
SET @@GLOBAL.RESTRICT_FK_ON_NON_STANDARD_KEY=IF(@OLD_RESTRICT_FK_ON_NON_STANDARD_KEY=0, 0, 1)"
1861+
);
1862+
}
18301863
}

0 commit comments

Comments
 (0)