Fixes task migration issue, closes #378

This commit is contained in:
Dane Everitt 2017-04-15 23:17:45 -04:00
parent f58858206e
commit b000b4da43
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -1,5 +1,6 @@
<?php <?php
use Pterodactyl\Models\Task;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
@ -17,11 +18,22 @@ class UpgradeTaskSystem extends Migration
$table->dropForeign(['server']); $table->dropForeign(['server']);
$table->renameColumn('server', 'server_id'); $table->renameColumn('server', 'server_id');
$table->unsignedInteger('user_id')->after('id'); $table->unsignedInteger('user_id')->nullable()->after('id');
$table->foreign('server_id')->references('id')->on('servers'); $table->foreign('server_id')->references('id')->on('servers');
$table->foreign('user_id')->references('id')->on('users'); $table->foreign('user_id')->references('id')->on('users');
}); });
DB::transaction(function () {
foreach(Task::all() as $task) {
$task->user_id = $task->server->owner_id;
$task->save();
}
});
Schema::table('tasks', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable(false)->change();
});
} }
/** /**