<?php

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('artwork_reports', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('artwork_id')->constrained('artworks')->cascadeOnDelete();
            $table->foreignId('reporter_user_id')->constrained('users')->cascadeOnDelete();
            $table->text('reason')->nullable();
            $table->timestamp('reported_at')->nullable();
            $table->timestamps();

            $table->unique(['artwork_id', 'reporter_user_id'], 'artwork_reports_unique_reporter_per_artwork');
            $table->index('reported_at');
        });
    }

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