<?php

use App\Enums\ApprovalStatus;
use App\Models\Cooperation;
use App\Models\PartnerMedia;
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('cooperation_proposals', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(Cooperation::class)->constrained()->cascadeOnDelete();
            $table->foreignIdFor(PartnerMedia::class)->constrained()->cascadeOnDelete();
            $table->text('description')->nullable();
            $table->string('e_catalog', 200)->nullable();
            $table->enum('status', ApprovalStatus::values())->default(ApprovalStatus::PENDING->value)->comment(ApprovalStatus::comment());
            $table->timestamp('submitted_at')->useCurrent();
            $table->timestamp('responded_at')->nullable();
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
        });
    }

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