<?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('master_menu_package_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('package_menu_id')->constrained('master_menu')->cascadeOnDelete();
            $table->foreignId('component_menu_id')->constrained('master_menu')->cascadeOnDelete();
            $table->unsignedInteger('qty')->default(1);
            $table->timestamps();

            $table->unique(['package_menu_id', 'component_menu_id'], 'menu_package_component_unique');
            $table->index('component_menu_id');
        });
    }

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