<?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('pengaduans', function (Blueprint $table) {
            $table->id();
            $table->string('nama_lengkap');
            $table->bigInteger('nik'); // Tambah panjang maksimal
            $table->string('email')->nullable(); // Sesuaikan dengan validasi controller
            $table->string('telepon', 20);
            $table->string('kategori');
            $table->text('isi_pengaduan');
            $table->string('lampiran')->nullable();
            $table->string('nomor_tiket', 20)->unique(); // Tambah panjang maksimal
            $table->enum('status', ['Pending', 'Diproses', 'Selesai'])->default('Pending');
            $table->timestamps();

            // Indexing untuk performa query yang lebih baik
            $table->index('nomor_tiket');
            $table->index('status');
            $table->index('created_at');
        });
    }

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