<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('saltacoda_riga_ordine_has_variante', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('saltacoda_riga_ordine_id')->unsigned()->nullable();
            $table->foreign('saltacoda_riga_ordine_id')->references('id')->on('saltacoda_riga_ordine')->onDelete('cascade')->name('sc_ro_has_var_riga_foreign');
            $table->bigInteger('variante_id')->unsigned()->nullable();
            $table->foreign('variante_id')->references('id')->on('variante_piatto')->onDelete('cascade')->name('sc_ro_has_var_variante_foreign');
            $table->string('nota')->nullable();
            $table->timestamps();

            $table->unique(['saltacoda_riga_ordine_id', 'variante_id'],'sc_ro_has_var_riga_var_unique');
        });
    }
    /**
     * Reverse the migrations.
     */

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