app(server): rename oom_disabled to oom_killer and invert existing values

This commit is contained in:
Matthew Penner 2023-01-17 12:11:31 -07:00
parent 450fba00bc
commit 7665eea14d
No known key found for this signature in database
16 changed files with 63 additions and 256 deletions

View file

@ -37,7 +37,7 @@ class ServerFactory extends Factory
'io' => 500,
'cpu' => 0,
'threads' => null,
'oom_disabled' => 0,
'oom_killer' => true,
'startup' => '/bin/bash echo "hello world"',
'image' => 'foo/bar:latest',
'allocation_limit' => null,

View file

@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->tinyInteger('oom_killer')->unsigned()->default(1)->after('oom_disabled');
});
DB::table('servers')->select(['id', 'oom_disabled'])->cursor()->each(function ($server) {
DB::table('servers')->where('id', $server->id)->update(['oom_killer' => !$server->oom_disabled]);
});
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('oom_disabled');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->tinyInteger('oom_disabled')->unsigned()->default(0)->after('oom_killer');
});
DB::table('servers')->select(['id', 'oom_killer'])->cursor()->each(function ($server) {
DB::table('servers')->where('id', $server->id)->update(['oom_disabled' => !$server->oom_killer]);
});
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('oom_killer');
});
}
};