<?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('tag_synonyms', function (Blueprint $table): void {
            $table->id();
            $table->unsignedBigInteger('tag_id');
            $table->string('synonym', 64);

            $table->unique(['tag_id', 'synonym']);
            $table->foreign('tag_id')->references('id')->on('tags')->cascadeOnDelete();
        });
    }

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