Skip to content

Commit b000b4d

Browse files
committed
Fixes task migration issue, closes pterodactyl#378
1 parent f588582 commit b000b4d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

database/migrations/2017_04_15_125021_UpgradeTaskSystem.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Pterodactyl\Models\Task;
34
use Illuminate\Support\Facades\Schema;
45
use Illuminate\Database\Schema\Blueprint;
56
use Illuminate\Database\Migrations\Migration;
@@ -17,11 +18,22 @@ public function up()
1718
$table->dropForeign(['server']);
1819

1920
$table->renameColumn('server', 'server_id');
20-
$table->unsignedInteger('user_id')->after('id');
21+
$table->unsignedInteger('user_id')->nullable()->after('id');
2122

2223
$table->foreign('server_id')->references('id')->on('servers');
2324
$table->foreign('user_id')->references('id')->on('users');
2425
});
26+
27+
DB::transaction(function () {
28+
foreach(Task::all() as $task) {
29+
$task->user_id = $task->server->owner_id;
30+
$task->save();
31+
}
32+
});
33+
34+
Schema::table('tasks', function (Blueprint $table) {
35+
$table->unsignedInteger('user_id')->nullable(false)->change();
36+
});
2537
}
2638

2739
/**

0 commit comments

Comments
 (0)