<?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('rec_item_pairs', function (Blueprint $table) {
            $table->unsignedBigInteger('a_artwork_id');
            $table->unsignedBigInteger('b_artwork_id');
            $table->double('weight')->default(0);
            $table->dateTime('updated_at');

            $table->unique(['a_artwork_id', 'b_artwork_id']);
            $table->index(['a_artwork_id', 'weight']);
            $table->index('b_artwork_id');
        });
    }

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