<?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('kas_rts', function (Blueprint $table) {
            $table->id();
            $table->date('tanggal');
            $table->enum('jenis', ['Pemasukan', 'Pengeluaran']);
            $table->string('kategori');
            $table->bigInteger('nominal');
            $table->text('keterangan');
            $table->string('bukti_url')->nullable();
            $table->foreignId('user_id')->constrained('users')->onDelete('restrict');
            $table->timestamps();
            
            $table->index(['jenis', 'tanggal']);
            $table->index('kategori');
        });
    }

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