File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -817,6 +817,28 @@ public function declarativeInstallSchema(array $request)
817
817
$ this ->getDeclarationInstaller ()->installSchema ($ request );
818
818
}
819
819
820
+ /**
821
+ * Clear memory tables
822
+ *
823
+ * Memory tables that used in old versions of Magento for indexing purposes should be cleaned
824
+ * Otherwise some supported DB solutions like Galeracluster may have replication error
825
+ * when memory engine will be switched to InnoDb
826
+ *
827
+ * @param SchemaSetupInterface $setup
828
+ * @return void
829
+ */
830
+ private function cleanMemoryTables (SchemaSetupInterface $ setup )
831
+ {
832
+ $ connection = $ setup ->getConnection ();
833
+ $ tables = $ connection ->getTables ();
834
+ foreach ($ tables as $ table ) {
835
+ $ tableData = $ connection ->showTableStatus ($ table );
836
+ if (isset ($ tableData ['Engine ' ]) && $ tableData ['Engine ' ] === 'MEMORY ' ) {
837
+ $ connection ->truncateTable ($ table );
838
+ }
839
+ }
840
+ }
841
+
820
842
/**
821
843
* Installs DB schema
822
844
*
@@ -835,6 +857,7 @@ public function installSchema(array $request)
835
857
$ setup = $ this ->setupFactory ->create ($ this ->context ->getResources ());
836
858
$ this ->setupModuleRegistry ($ setup );
837
859
$ this ->setupCoreTables ($ setup );
860
+ $ this ->cleanMemoryTables ($ setup );
838
861
$ this ->log ->log ('Schema creation/updates: ' );
839
862
$ this ->declarativeInstallSchema ($ request );
840
863
$ this ->handleDBSchemaData ($ setup , 'schema ' , $ request );
Original file line number Diff line number Diff line change @@ -326,9 +326,10 @@ public function testInstall(array $request, array $logMessages)
326
326
$ setup = $ this ->createMock (Setup::class);
327
327
$ table = $ this ->createMock (Table::class);
328
328
$ connection = $ this ->getMockBuilder (AdapterInterface::class)
329
- ->setMethods (['getSchemaListener ' , 'newTable ' ])
329
+ ->setMethods (['getSchemaListener ' , 'newTable ' , ' getTables ' ])
330
330
->getMockForAbstractClass ();
331
331
$ connection ->expects ($ this ->any ())->method ('getSchemaListener ' )->willReturn ($ this ->schemaListenerMock );
332
+ $ connection ->expects ($ this ->once ())->method ('getTables ' )->willReturn ([]);
332
333
$ setup ->expects ($ this ->any ())->method ('getConnection ' )->willReturn ($ connection );
333
334
$ table ->expects ($ this ->any ())->method ('addColumn ' )->willReturn ($ table );
334
335
$ table ->expects ($ this ->any ())->method ('setComment ' )->willReturn ($ table );
You can’t perform that action at this time.
0 commit comments