From e64b66c823a3d8b5f2cd76b5dd19fa701cf169c8 Mon Sep 17 00:00:00 2001 From: Gio <34938366+giomxx@users.noreply.github.com> Date: Thu, 11 Jul 2024 21:10:55 +0100 Subject: [PATCH 1/2] clear allocation notes on server deletion --- app/Services/Servers/ServerDeletionService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Services/Servers/ServerDeletionService.php b/app/Services/Servers/ServerDeletionService.php index a83c8feb6a..57cce873b4 100644 --- a/app/Services/Servers/ServerDeletionService.php +++ b/app/Services/Servers/ServerDeletionService.php @@ -35,7 +35,7 @@ public function withForce(bool $bool = true): self } /** - * Delete a server from the panel and remove any associated databases from hosts. + * Delete a server from the panel, clear any allocation notes, and remove any associated databases from hosts. * * @throws \Throwable * @throws \Pterodactyl\Exceptions\DisplayException @@ -77,7 +77,12 @@ public function handle(Server $server): void } } + // clear any allocation notes for the server + $server->allocations->each(function ($allocation) { + $allocation->update(['notes' => null]); + }); + $server->delete(); }); } -} +} \ No newline at end of file From b8bcb3ae1d90d1e919ec7f3593edc09a70043349 Mon Sep 17 00:00:00 2001 From: Gio <34938366+giomxx@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:21:43 +0000 Subject: [PATCH 2/2] add db migration to clear unused allocation notes --- ...3_091852_clear_unused_allocation_notes.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php diff --git a/database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php b/database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php new file mode 100644 index 0000000000..9e2b36c8b1 --- /dev/null +++ b/database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php @@ -0,0 +1,26 @@ +where('server_id', null) + ->whereNot('notes', null) + ->update(['notes' => null]); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Reverse not needed + } +}; \ No newline at end of file