From f4abceac05d749d7d6b8e480d8b379f8e3dfc981 Mon Sep 17 00:00:00 2001 From: Cristiano Pacheco Date: Mon, 19 Feb 2024 16:55:04 -0300 Subject: [PATCH] [#39] - Adds a data patch to handle the data migration from run_as_root_message to run_as_root_queue_error_message database table --- .../HandleMigrationFromMessageTablePatch.php | 55 +++++++++++++++++++ src/etc/db_schema.xml | 3 +- src/etc/db_schema_whitelist.json | 21 +------ 3 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 src/Setup/Patch/Data/HandleMigrationFromMessageTablePatch.php diff --git a/src/Setup/Patch/Data/HandleMigrationFromMessageTablePatch.php b/src/Setup/Patch/Data/HandleMigrationFromMessageTablePatch.php new file mode 100644 index 0000000..fe81e52 --- /dev/null +++ b/src/Setup/Patch/Data/HandleMigrationFromMessageTablePatch.php @@ -0,0 +1,55 @@ +moduleDataSetup->startSetup(); + + $connection = $this->moduleDataSetup->getConnection(); + $oldMessageTable = $this->moduleDataSetup->getTable('run_as_root_message'); + $newMessageTable = $this->moduleDataSetup->getTable('run_as_root_queue_error_message'); + + if (!$connection->isTableExists($oldMessageTable) || !$connection->isTableExists($newMessageTable)) { + $this->moduleDataSetup->endSetup(); + return $this; + } + + $select = $connection->select()->from($oldMessageTable); + + $connection->query($connection->insertFromSelect($select, $newMessageTable)); + + $connection->dropTable($oldMessageTable); + + $this->moduleDataSetup->endSetup(); + + return $this; + } + + public static function getDependencies(): array + { + return []; + } +} diff --git a/src/etc/db_schema.xml b/src/etc/db_schema.xml index d64f828..b4060f8 100644 --- a/src/etc/db_schema.xml +++ b/src/etc/db_schema.xml @@ -1,8 +1,7 @@ - +
diff --git a/src/etc/db_schema_whitelist.json b/src/etc/db_schema_whitelist.json index a50490e..b011b59 100644 --- a/src/etc/db_schema_whitelist.json +++ b/src/etc/db_schema_whitelist.json @@ -1,23 +1,4 @@ { - "run_as_root_message": { - "column": { - "entity_id": true, - "topic_name": true, - "message_body": true, - "failure_description": true, - "creation_time": true, - "update_time": true, - "resource_id": true, - "created_at": true, - "updated_at": true - }, - "index": { - "RUN_AS_ROOT_MESSAGE_TOPIC_NAME": true - }, - "constraint": { - "PRIMARY": true - } - }, "run_as_root_queue_error_message": { "column": { "entity_id": true, @@ -34,4 +15,4 @@ "PRIMARY": true } } -} \ No newline at end of file +}