Files
pterodactyl-panel/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php
T

46 lines
1.4 KiB
PHP
Raw Normal View History

2017-03-10 18:25:12 -05:00
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
2017-09-25 21:43:01 -05:00
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
2017-03-10 18:25:12 -05:00
*/
use Illuminate\Database\Migrations\Migration;
class MigrateToNewServiceSystem extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
DB::transaction(function () {
2017-10-06 23:57:53 -05:00
$service = DB::table('services')->where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first();
if (! $service) {
return;
2017-03-12 18:05:30 -04:00
}
2017-10-06 23:57:53 -05:00
$options = DB::table('service_options')->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';
}
$item->save();
});
2017-03-12 18:05:30 -04:00
});
2017-03-10 18:25:12 -05:00
}
/**
* Reverse the migrations.
*/
public function down()
{
// Not doing reversals right now...
}
}