Skip to content

Commit 02f7d4d

Browse files
giomxxJackinatox
authored andcommitted
Clear allocation notes on server deletion (pterodactyl#5157)
1 parent 72626ad commit 02f7d4d

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1717
* Fixes node description not being settable via the API.
1818
* Fixes 0-bytes files returning an error when attempting to upload.
1919
* Fixes nodes displaying the first available location even when that field was not edited and the node has a different value set.
20+
* Fixes allocation notes not being reset when a server is deleted. ([#5157](https://github.com/pterodactyl/panel/pull/5157))
2021

2122
### Changed
2223
* Minimum NodeJS version updated to 22 for building.

app/Services/Servers/ServerDeletionService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function withForce(bool $bool = true): self
3535
}
3636

3737
/**
38-
* Delete a server from the panel and remove any associated databases from hosts.
38+
* Delete a server from the panel, clear any allocation notes, and remove any associated databases from hosts.
3939
*
4040
* @throws \Throwable
4141
* @throws \Pterodactyl\Exceptions\DisplayException
@@ -77,6 +77,10 @@ public function handle(Server $server): void
7777
}
7878
}
7979

80+
// clear any allocation notes for the server
81+
$server->allocations()->update(['notes' => null]);
82+
83+
8084
$server->delete();
8185
});
8286
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\DB;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
return new class () extends Migration {
7+
/**
8+
* Run the migrations.
9+
*/
10+
public function up(): void
11+
{
12+
13+
DB::table('allocations')
14+
->whereNull('server_id')
15+
->update(['notes' => null]);
16+
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
// Reverse not needed
25+
}
26+
};

0 commit comments

Comments
 (0)