<?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('letters', function (Blueprint $table) {
            $table->id();
            $table->string('nombor_surat', 80);
            $table->string('nama_surat', 255);
            $table->enum('jenis', ['masuk', 'keluar']);
            $table->date('tarikh_surat');
            $table->string('created_by', 120)->nullable();
            $table->timestamps();

            $table->index(['jenis', 'tarikh_surat']);
            $table->index(['tarikh_surat']);
        });
    }

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