mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-24 23:11:08 +02:00
Unwrap transaction
This commit is contained in:
parent
eff8e509ef
commit
b24ff8bb26
@ -12,42 +12,46 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
DB::transaction(function () {
|
Schema::table('server_transfers', function (Blueprint $table) {
|
||||||
Schema::table('server_transfers', function (Blueprint $table) {
|
$table->dropColumn(['old_allocation', 'new_allocation', 'old_additional_allocations', 'new_additional_allocations']);
|
||||||
$table->dropColumn(['old_allocation', 'new_allocation', 'old_additional_allocations', 'new_additional_allocations']);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Schema::table('servers', function (Blueprint $table) {
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
$table->json('ports')->nullable();
|
$table->json('ports')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::table('servers')->update(['ports' => '[]']);
|
DB::table('servers')->update(['ports' => '[]']);
|
||||||
|
|
||||||
Schema::table('servers', function (Blueprint $table) {
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
$table->json('ports')->change();
|
$table->json('ports')->change();
|
||||||
});
|
});
|
||||||
|
|
||||||
$portMappings = [];
|
$portMappings = [];
|
||||||
foreach (DB::table('allocations')->get() as $allocation) {
|
foreach (DB::table('allocations')->get() as $allocation) {
|
||||||
$portMappings[$allocation->server_id][] = "$allocation->ip:$allocation->port";
|
$portMappings[$allocation->server_id][] = "$allocation->ip:$allocation->port";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($portMappings as $serverId => $ports) {
|
||||||
|
DB::table('servers')
|
||||||
|
->where('id', $serverId)
|
||||||
|
->update(['ports' => json_encode($ports)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
try {
|
||||||
|
$table->dropForeign(['allocation_id']);
|
||||||
|
} catch (Exception) {
|
||||||
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($portMappings as $serverId => $ports) {
|
$table->dropUnique(['allocation_id']);
|
||||||
DB::table('servers')
|
$table->dropColumn(['allocation_id']);
|
||||||
->where('id', $serverId)
|
});
|
||||||
->update(['ports' => json_encode($ports)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Schema::table('servers', function (Blueprint $table) {
|
Schema::dropIfExists('allocations');
|
||||||
$table->dropUnique(['allocation_id']);
|
|
||||||
$table->dropColumn(['allocation_id']);
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::dropIfExists('allocations');
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
|
$table->boolean('strict_ports')->default(true);
|
||||||
Schema::table('nodes', function (Blueprint $table) {
|
|
||||||
$table->boolean('strict_ports')->default(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user