<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * PRC-1143 — konsolide şema: `menus` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('menus', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('brand_id')->nullable();
            $t->string('slug', 64);
            $t->string('name', 120);
            $t->boolean('is_active')->default(1);
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('brand_id', 'menus_brand_id_index');
            $t->unique(['brand_id', 'slug'], 'menus_brand_id_slug_unique');
            $t->foreign('brand_id', 'menus_brand_id_foreign')->references('id')->on('brands')->onDelete('cascade');
        });
    }

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