<?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_translations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('artwork_id')->constrained()->cascadeOnDelete();
            $table->char('locale', 2);

            $table->string('title', 150);
            $table->text('description')->nullable();

            $table->timestamps();
            $table->softDeletes();

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

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