File tree Expand file tree Collapse file tree 2 files changed +52
-5
lines changed Expand file tree Collapse file tree 2 files changed +52
-5
lines changed Original file line number Diff line number Diff line change 10
10
/**
11
11
* The reason for this class is to handle the migration from the old message table to the new one.
12
12
* This is necessary because errors are being generated during integration testes while using
13
- * the onCreate="migrateDataFromAnotherTable('old_table ')" in the db_schema.xml
13
+ * the onCreate="migrateDataFromAnotherTable('run_as_root_message ')" in the db_schema.xml
14
14
*/
15
- class HandleMigrationFromMessageTablePatch implements DataPatchInterface
15
+ class CopyDataFromOldMessageTable implements DataPatchInterface
16
16
{
17
17
public function __construct (
18
18
private readonly ModuleDataSetupInterface $ moduleDataSetup ,
@@ -38,11 +38,8 @@ public function apply(): self
38
38
}
39
39
40
40
$ select = $ connection ->select ()->from ($ oldMessageTable );
41
-
42
41
$ connection ->query ($ connection ->insertFromSelect ($ select , $ newMessageTable ));
43
42
44
- $ connection ->dropTable ($ oldMessageTable );
45
-
46
43
$ this ->moduleDataSetup ->endSetup ();
47
44
48
45
return $ this ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace RunAsRoot \MessageQueueRetry \Setup \Patch \Data ;
6
+
7
+ use Magento \Framework \Setup \ModuleDataSetupInterface ;
8
+ use Magento \Framework \Setup \Patch \DataPatchInterface ;
9
+
10
+ /**
11
+ * The reason for this class is to handle the migration from the old message table to the new one.
12
+ * This is necessary because errors are being generated during integration testes while using
13
+ * the onCreate="migrateDataFromAnotherTable('run_as_root_message')" in the db_schema.xml
14
+ */
15
+ class DeleteOldMessageTable implements DataPatchInterface
16
+ {
17
+ public function __construct (
18
+ private readonly ModuleDataSetupInterface $ moduleDataSetup ,
19
+ ) {
20
+ }
21
+
22
+ public function getAliases (): array
23
+ {
24
+ return [];
25
+ }
26
+
27
+ public function apply (): self
28
+ {
29
+ $ this ->moduleDataSetup ->startSetup ();
30
+
31
+ $ connection = $ this ->moduleDataSetup ->getConnection ();
32
+ $ oldMessageTable = $ this ->moduleDataSetup ->getTable ('run_as_root_message ' );
33
+
34
+ if (!$ connection ->isTableExists ($ oldMessageTable )) {
35
+ $ this ->moduleDataSetup ->endSetup ();
36
+ return $ this ;
37
+ }
38
+
39
+ $ connection ->dropTable ($ oldMessageTable );
40
+
41
+ $ this ->moduleDataSetup ->endSetup ();
42
+
43
+ return $ this ;
44
+ }
45
+
46
+ public static function getDependencies (): array
47
+ {
48
+ return [CopyDataFromOldMessageTable::class];
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments