<?php

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

/**
 * Availability, counted from our own checks.
 *
 * Uptime Kuma knows the figure but the REST bridge in front of it only answers
 * "healthy, yes or no" — and waiting for the bridge to grow an endpoint would
 * leave the panel without the number indefinitely. The monitoring sync already
 * asks that question on a schedule; counting the answers gives a percentage
 * that is ours, explainable, and available today.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('instance_metrics', function (Blueprint $table) {
            $table->unsignedInteger('checks_total')->default(0);
            $table->unsignedInteger('checks_ok')->default(0);
        });
    }

    public function down(): void
    {
        Schema::table('instance_metrics', function (Blueprint $table) {
            $table->dropColumn(['checks_total', 'checks_ok']);
        });
    }
};
