mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user