<?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('checks', function (Blueprint $table) {
            $table->id();
            $table->foreignId('checkbook_id')->constrained()->onDelete('cascade');
            $table->string('check_number');
            $table->enum('status', ['unused', 'used', 'cancelled', 'cashed', 'rejected'])->default('unused');
            $table->decimal('amount', 15, 2)->nullable();
            $table->string('payee')->nullable();
            $table->date('issue_date')->nullable();
            $table->date('cash_date')->nullable();
            $table->text('notes')->nullable();
            $table->timestamps();
            
            $table->unique(['checkbook_id', 'check_number']);
        });
    }

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