<?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('repayments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('lender_id')->constrained('lenders')->onDelete('cascade');
            $table->foreignId('credit_id')->constrained('credits')->onDelete('cascade');
            $table->string('code', 15)->nullable();
            $table->decimal('amount', 15, 2);
            $table->date('date');
            $table->text('observation')->nullable();
            $table->string('attachment')->nullable();
            $table->boolean('is_valid')->default(0);
            $table->datetime('validation_date')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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