<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('olt_onus', function (Blueprint $table) {
            $table->id();
            $table->foreignId('olt_port_id')->constrained()->onDelete('cascade');
            $table->integer('onu_number');
            $table->string('serial_number');
            $table->string('onu_type')->default('ZTE-F680');
            $table->string('customer_name')->nullable();
            $table->string('customer_description')->nullable();
            $table->integer('vlan')->default(510);
            $table->string('tcont_profile')->default('UP1000M');
            $table->integer('service_port')->default(2);
            $table->string('service_name')->default('INTERNET');
            $table->enum('status', ['authorized', 'pending', 'disabled'])->default('authorized');
            $table->text('raw_config')->nullable();
            $table->timestamp('authorized_at')->nullable();
            $table->foreignId('authorized_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('olt_onus');
    }
};
