<?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_artwork_recs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('artwork_id');
            $table->string('rec_type', 40); // similar_hybrid, similar_visual, similar_tags, similar_behavior
            $table->json('recs');            // ordered array of artwork_ids
            $table->string('model_version', 30)->default('sim_v1');
            $table->dateTime('computed_at');
            $table->timestamps();

            $table->unique(['artwork_id', 'rec_type', 'model_version']);
            $table->index(['artwork_id', 'rec_type']);
        });
    }

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