<?php

use App\Enums\CooperationStatus;
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('cooperations', function (Blueprint $table) {
            $table->id();
            $table->string('title', 200);
            $table->date('initial_submission_date')->index();
            $table->date('final_submission_date')->index();
            $table->text('description');
            $table->unsignedInteger('payment_amount')->nullable();
            $table->date('payment_date')->nullable();
            $table->date('completed_at')->nullable();
            $table->enum('status', CooperationStatus::values())->default(CooperationStatus::PENDING->value)->comment(CooperationStatus::comment())->index();
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
            $table->softDeletes();
        });
    }

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