<?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('send_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('device_id')->constrained()->cascadeOnDelete();
            $table->string('mode');          // buka | tutup
            $table->boolean('success');
            $table->text('message')->nullable();
            $table->unsignedInteger('duration_ms')->default(0);
            $table->string('triggered_by')->default('manual'); // manual | schedule
            $table->timestamps();
        });
    }

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