<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('servers', function (Blueprint $table) {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->string('name');
            $table->string('hostname')->nullable();
            $table->string('ip');
            $table->unsignedSmallInteger('ssh_port')->default(22);
            $table->string('os')->nullable();
            $table->string('status')->default('offline'); // online|warning|offline
            $table->unsignedTinyInteger('cpu')->default(0);
            $table->unsignedTinyInteger('mem')->default(0);
            $table->unsignedTinyInteger('disk')->default(0);
            $table->string('uptime')->nullable();
            $table->json('specs')->nullable();
            $table->timestamp('last_seen_at')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('servers');
    }
};
