<?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_files', function (Blueprint $table) {
            $table->unsignedBigInteger('artwork_id');
            $table->string('variant', 16);
            $table->string('path');
            $table->string('mime', 64);
            $table->unsignedBigInteger('size');

            $table->primary(['artwork_id', 'variant']);
            $table->index('variant');
            $table->foreign('artwork_id')->references('id')->on('artworks')->cascadeOnDelete();
        });
    }

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