From 873ddd204d7cf11ec404edf94546d8b89c982df5 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 31 Oct 2016 17:15:30 -0400 Subject: [PATCH] Hotfix for broken rc.1 installs and upgrades --- CHANGELOG.md | 7 +++- ...6_09_17_194246_add_docker_image_column.php | 18 ++++++----- ..._09_29_213518_rename_double_insurgency.php | 14 ++++---- ...16_10_30_000949_add_ark_service_option.php | 32 ++++++++++--------- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4980efb73..df19739a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,12 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. -## v0.5.0-pre.4 (Bodacious Boreopterus) +## v0.5.0-rc.2 (Bodacious Boreopterus) + +### Fixed +* Fixes a bug that would cause MySQL errors when attempting to install the panel rather than upgrading. + +## v0.5.0-rc.1 (Bodacious Boreopterus) ### Added * Foreign keys are now enabled on all tables that the panel makes use of to prevent accidental data deletion when associated with other tables. diff --git a/database/migrations/2016_09_17_194246_add_docker_image_column.php b/database/migrations/2016_09_17_194246_add_docker_image_column.php index 9b667828c..bea676a08 100644 --- a/database/migrations/2016_09_17_194246_add_docker_image_column.php +++ b/database/migrations/2016_09_17_194246_add_docker_image_column.php @@ -20,15 +20,17 @@ class AddDockerImageColumn extends Migration }); // Populate the column - $servers = Server::select( - 'servers.id', - 'service_options.docker_image as s_optionImage' - )->join('service_options', 'service_options.id', '=', 'servers.option')->get(); + DB::transaction(function () { + $servers = DB::table('servers')->select( + 'servers.id', + 'service_options.docker_image as s_optionImage' + )->join('service_options', 'service_options.id', '=', 'servers.option')->get(); - foreach ($servers as $server) { - $server->image = $server->s_optionImage; - $server->save(); - } + foreach ($servers as $server) { + $server->image = $server->s_optionImage; + $server->save(); + } + }); } /** diff --git a/database/migrations/2016_09_29_213518_rename_double_insurgency.php b/database/migrations/2016_09_29_213518_rename_double_insurgency.php index 79a11661b..6c0ea8070 100644 --- a/database/migrations/2016_09_29_213518_rename_double_insurgency.php +++ b/database/migrations/2016_09_29_213518_rename_double_insurgency.php @@ -4,8 +4,6 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -use Pterodactyl\Models\ServiceOptions; - class RenameDoubleInsurgency extends Migration { /** @@ -15,11 +13,13 @@ class RenameDoubleInsurgency extends Migration */ public function up() { - $model = ServiceOptions::where('parent_service', 2)->where('id', 3)->where('name', 'Insurgency')->first(); - if ($model) { - $model->name = 'Team Fortress 2'; - $model->save(); - } + DB::transaction(function () { + $model = DB::table('service_options')->where('parent_service', 2)->where('id', 3)->where('name', 'Insurgency')->first(); + if ($model) { + $model->name = 'Team Fortress 2'; + $model->save(); + } + }); } /** diff --git a/database/migrations/2016_10_30_000949_add_ark_service_option.php b/database/migrations/2016_10_30_000949_add_ark_service_option.php index 487e29f5d..8d1e277f1 100644 --- a/database/migrations/2016_10_30_000949_add_ark_service_option.php +++ b/database/migrations/2016_10_30_000949_add_ark_service_option.php @@ -4,10 +4,6 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOptions; -use Pterodactyl\Models\ServiceVariables; - class AddArkServiceOption extends Migration { /** @@ -18,12 +14,12 @@ class AddArkServiceOption extends Migration public function up() { DB::transaction(function () { - $service = Service::select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); + $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); if (!$service) { exit('No service could be found.'); } - $option = ServiceOptions::create([ + $oid = DB::table('service_options')->getInsertId([ 'parent_service' => $service->id, 'name' => 'Ark: Survival Evolved', 'description' => 'As a man or woman stranded, naked, freezing, and starving on the unforgiving shores of a mysterious island called ARK, use your skill and cunning to kill or tame and ride the plethora of leviathan dinosaurs and other primeval creatures roaming the land. Hunt, harvest resources, craft items, grow crops, research technologies, and build shelters to withstand the elements and store valuables, all while teaming up with (or preying upon) hundreds of other players to survive, dominate... and escape! — Gamepedia: ARK', @@ -33,8 +29,8 @@ class AddArkServiceOption extends Migration 'startup' => 'TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}}' ]); - ServiceVariables::create([ - 'option_id' => $option->id, + DB::table('service_variables')->insert([ + 'option_id' => $oid, 'name' => 'Server Password', 'description' => 'If specified, players must provide this password to join the server.', 'env_variable' => 'ARK_PASSWORD', @@ -45,8 +41,8 @@ class AddArkServiceOption extends Migration 'regex' => '/^(\w\.*)$/' ]); - ServiceVariables::create([ - 'option_id' => $option->id, + DB::table('service_variables')->insert([ + 'option_id' => $oid, 'name' => 'Admin Password', 'description' => 'If specified, players must provide this password (via the in-game console) to gain access to administrator commands on the server.', 'env_variable' => 'ARK_ADMIN_PASSWORD', @@ -57,8 +53,8 @@ class AddArkServiceOption extends Migration 'regex' => '/^(\w\.*)$/' ]); - ServiceVariables::create([ - 'option_id' => $option->id, + DB::table('service_variables')->insert([ + 'option_id' => $oid, 'name' => 'Maximum Players', 'description' => 'Specifies the maximum number of players that can play on the server simultaneously.', 'env_variable' => 'SERVER_MAX_PLAYERS', @@ -80,9 +76,15 @@ class AddArkServiceOption extends Migration public function down() { DB::transaction(function () { - $service = Service::select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); - $option = ServiceOptions::where('parent_service', $service->id)->where('tag', 'ark')->delete(); - $variables = ServiceVariables::where('option_id', $option->id)->delete(); + $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); + + if ($service) { + $option = DB::table('service_options')->where('parent_service', $service->id)->where('tag', 'ark')->first(); + + if ($option) { + $variables = DB::table('service_variables')->where('option_id', $option->id)->delete(); + } + } }); } }