<?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('user_received_comment_reads', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('artwork_comment_id')->constrained('artwork_comments')->cascadeOnDelete();
            $table->timestamp('read_at');
            $table->timestamps();

            $table->unique(['user_id', 'artwork_comment_id'], 'ucr_user_comment_unique');
            $table->index(['user_id', 'read_at'], 'ucr_user_read_at_index');
        });
    }

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