Convert Virtual Machine pages to Laravel (#12287)

* Convert Virtual Machine pages to Laravel

* wip

* wip

* wip

* wip

* wip

* wip

* delete

* wip

* wip

* move powerStateLabel
This commit is contained in:
Jellyfrog
2020-11-11 01:15:20 +01:00
committed by GitHub
parent ac5920f45c
commit cfd9dce620
24 changed files with 363 additions and 237 deletions

View File

@@ -0,0 +1,45 @@
<?php
use App\Models\Vminfo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use LibreNMS\Enum\PowerState;
class AddPowerstateEnumToVminfo extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Vminfo::select('id', 'vmwVmState')->chunk(100, function ($vms) {
foreach ($vms as $vm) {
if (is_numeric($vm->vmwVmState)) {
continue;
}
$vm->vmwVmState = PowerState::STATES[strtolower($vm->vmwVmState)];
$vm->update();
}
});
Schema::table('vminfo', function (Blueprint $table) {
$table->smallInteger('vmwVmState')->unsigned()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('vminfo', function (Blueprint $table) {
$table->string('vmwVmState', 128)->change();
});
}
}