diff --git a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php index 374219539..5a1df2afb 100644 --- a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php +++ b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php @@ -13,11 +13,29 @@ class DeleteServiceExecutableOption extends Migration */ public function up() { - Schema::table('services', function (Blueprint $table) { - $table->dropColumn('executable'); - $table->renameColumn('file', 'folder'); - $table->text('description')->nullable()->change(); - $table->text('startup')->nullable()->change(); + DB::transaction(function () { + Schema::table('services', function (Blueprint $table) { + $table->renameColumn('file', 'folder'); + $table->text('description')->nullable()->change(); + $table->text('startup')->nullable()->change(); + }); + + // Attempt to fix any startup commands for servers + // that we possibly can. + foreach (ServiceOption::with('servers')->get() as $option) { + $option->servers->each(function ($s) use ($option) { + $prepend = $option->display_executable; + $prepend = ($prepend === './ShooterGameServer') ? './ShooterGame/Binaries/Linux/ShooterGameServer' : $prepend; + $prepend = ($prepend === 'TerrariaServer.exe') ? 'mono TerrariaServer.exe' : $prepend; + + $s->startup = $prepend . ' ' . $s->startup; + $s->save(); + }); + } + + Schema::table('services', function (Blueprint $table) { + $table->dropColumn('executable'); + }); }); } diff --git a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php b/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php index 71af419b0..f2c50cdd7 100644 --- a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php +++ b/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php @@ -13,18 +13,16 @@ class AddNewServiceOptionsColumns extends Migration */ public function up() { - DB::transaction(function () { - Schema::table('service_options', function (Blueprint $table) { - $table->dropColumn('executable'); + Schema::table('service_options', function (Blueprint $table) { + $table->dropColumn('executable'); - $table->unsignedInteger('config_from')->nullable()->after('docker_image'); - $table->string('config_stop')->nullable()->after('docker_image'); - $table->text('config_logs')->nullable()->after('docker_image'); - $table->text('config_startup')->nullable()->after('docker_image'); - $table->text('config_files')->nullable()->after('docker_image'); + $table->unsignedInteger('config_from')->nullable()->after('docker_image'); + $table->string('config_stop')->nullable()->after('docker_image'); + $table->text('config_logs')->nullable()->after('docker_image'); + $table->text('config_startup')->nullable()->after('docker_image'); + $table->text('config_files')->nullable()->after('docker_image'); - $table->foreign('config_from')->references('id')->on('service_options'); - }); + $table->foreign('config_from')->references('id')->on('service_options'); }); } @@ -35,18 +33,16 @@ class AddNewServiceOptionsColumns extends Migration */ public function down() { - DB::transaction(function () { - Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('config_from'); + Schema::table('service_options', function (Blueprint $table) { + $table->dropForeign('config_from'); - $table->dropColumn('config_from'); - $table->dropColumn('config_stop'); - $table->dropColumn('config_logs'); - $table->dropColumn('config_startup'); - $table->dropColumn('config_files'); + $table->dropColumn('config_from'); + $table->dropColumn('config_stop'); + $table->dropColumn('config_logs'); + $table->dropColumn('config_startup'); + $table->dropColumn('config_files'); - $table->string('executable')->after('docker_image')->nullable(); - }); + $table->string('executable')->after('docker_image')->nullable(); }); } } diff --git a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php index 471ad8078..9f935fff8 100644 --- a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php +++ b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php @@ -34,20 +34,22 @@ class MigrateToNewServiceSystem extends Migration */ public function up() { - $service = Service::where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); - if (! $service) { - return; - } - - $options = ServiceOption::where('service_id', $service->id)->get(); - $options->each(function ($item) use ($options) { - if ($item->tag === 'srcds' && $item->name === 'Insurgency') { - $item->tag = 'insurgency'; - } elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') { - $item->tag = 'tf2'; - } elseif ($item->tag === 'srcds' && $item->name === 'Custom Source Engine Game') { - $item->tag = 'source'; + DB::transaction(function () { + $service = Service::where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); + if (! $service) { + return; } + + $options = ServiceOption::where('service_id', $service->id)->get(); + $options->each(function ($item) use ($options) { + if ($item->tag === 'srcds' && $item->name === 'Insurgency') { + $item->tag = 'insurgency'; + } elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') { + $item->tag = 'tf2'; + } elseif ($item->tag === 'srcds' && $item->name === 'Custom Source Engine Game') { + $item->tag = 'source'; + } + }); }); }