<?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('designation_user', function (Blueprint $table) {
            // Consistency
            $table->engine    = 'InnoDB';
            $table->charset   = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';

            $table->id(); // BIGINT UNSIGNED AI

            // NOT NULL per dump
            $table->unsignedBigInteger('designation_id');
            $table->unsignedBigInteger('user_id');

            $table->timestamps(); // created_at, updated_at (nullable)

            // Plain index name exactly as in your dump
            $table->index('user_id', 'designation_user_user_id_foreign');

            // (Optional) prevent duplicates of the pair:
            // $table->unique(['designation_id','user_id'], 'designation_user_unique_pair');
        });
    }

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

