Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear allocation notes on server deletion #5157

Open
wants to merge 3 commits into
base: 1.0-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/Services/Servers/ServerDeletionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('allocations')
->where('server_id', null)
->whereNot('notes', null)
->update(['notes' => null]);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
// Reverse not needed
}
};