<?php

declare(strict_types=1);

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('world_editorial_suggestion_states', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('world_id')->constrained()->cascadeOnDelete();
            $table->string('related_type', 40);
            $table->unsignedBigInteger('related_id');
            $table->string('status', 40);
            $table->string('section_key', 80)->nullable();
            $table->foreignId('acted_by_user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();

            $table->unique(['world_id', 'related_type', 'related_id'], 'world_editorial_suggestion_states_unique');
            $table->index(['world_id', 'status'], 'world_editorial_suggestion_states_status_idx');
        });
    }

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