<?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('installments', function (Blueprint $table) {
            $table->id();

            $table->foreignId('entry_id')
                  ->constrained('entries')
                  ->onDelete('cascade');

            $table->date('proc_date');                // processing date
            $table->decimal('amount', 12, 2);

            $table->string('description')->nullable();
            $table->string('region')->nullable();

            $table->enum('status', [
                'Pending',
                'Loading',
                'Packed',
                'Dispatched',
                'Delivered'
            ])->default('Pending');

            $table->timestamps();
        });
    }

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