From 50fdf7b3c2976b9e8920ea59b550cf3b600de777 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 7 Aug 2025 08:00:35 -0400 Subject: [PATCH 1/2] Archive tables --- src/migrations/Install.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/migrations/Install.php b/src/migrations/Install.php index 72f08b6..2089475 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -18,7 +18,7 @@ class Install extends Migration public function safeUp(): bool { // Cleanup - $this->_dropTables(); + $this->_archiveTables(); // Create the webhookgroups table $this->createTable('{{%webhookgroups}}', [ @@ -91,6 +91,13 @@ public function safeDown(): bool return true; } + private function _archiveTables(): void + { + $this->archiveTableIfExists('{{%webhookrequests}}'); + $this->archiveTableIfExists('{{%webhooks}}'); + $this->archiveTableIfExists('{{%webhookgroups}}'); + } + private function _dropTables(): void { $this->dropTableIfExists('{{%webhookrequests}}'); From 4a4a862872b1ebd154a8516977e7c1f7d227b5b6 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 7 Aug 2025 08:55:18 -0400 Subject: [PATCH 2/2] Simplify --- src/migrations/Install.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/migrations/Install.php b/src/migrations/Install.php index 2089475..f24b60d 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -17,10 +17,8 @@ class Install extends Migration */ public function safeUp(): bool { - // Cleanup - $this->_archiveTables(); - // Create the webhookgroups table + $this->archiveTableIfExists('{{%webhookgroups}}'); $this->createTable('{{%webhookgroups}}', [ 'id' => $this->primaryKey(), 'name' => $this->string()->notNull(), @@ -30,6 +28,7 @@ public function safeUp(): bool ]); // Create the webhooks table + $this->archiveTableIfExists('{{%webhooks}}'); $this->createTable('{{%webhooks}}', [ 'id' => $this->primaryKey(), 'groupId' => $this->integer()->null(), @@ -52,6 +51,7 @@ public function safeUp(): bool ]); // Create the webhookrequests table + $this->archiveTableIfExists('{{%webhookrequests}}'); $this->createTable('{{%webhookrequests}}', [ 'id' => $this->primaryKey(), 'webhookId' => $this->integer(), @@ -86,22 +86,11 @@ public function safeUp(): bool * @inheritdoc */ public function safeDown(): bool - { - $this->_dropTables(); - return true; - } - - private function _archiveTables(): void - { - $this->archiveTableIfExists('{{%webhookrequests}}'); - $this->archiveTableIfExists('{{%webhooks}}'); - $this->archiveTableIfExists('{{%webhookgroups}}'); - } - - private function _dropTables(): void { $this->dropTableIfExists('{{%webhookrequests}}'); $this->dropTableIfExists('{{%webhooks}}'); $this->dropTableIfExists('{{%webhookgroups}}'); + + return true; } }