<?php

use App\Enums\IssueSentiment;
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('issue_management', function (Blueprint $table) {
            $table->id();
            $table->foreignId('location_id')->constrained()->cascadeOnDelete();
            $table->foreignId('sub_location_id')->nullable()->constrained()->nullOnDelete();
            $table->foreignId('classification_id')->constrained()->cascadeOnDelete();
            $table->foreignId('sub_classification_id')->nullable()->constrained()->nullOnDelete();
            $table->foreignId('media_monitoring_id')->constrained()->cascadeOnDelete();
            $table->enum('issue', IssueSentiment::values())->default(IssueSentiment::NEUTRAL->value)->comment(IssueSentiment::comment())->index();
            $table->enum('response', IssueSentiment::values())->default(IssueSentiment::NEUTRAL->value)->comment(IssueSentiment::comment())->index();
            $table->text('description');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
            $table->softDeletes();
        });
    }

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