<?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('bacheca_has_contenuto', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('bacheca_id')->unsigned()->nullable();
            $table->bigInteger('contenuto_id')->unsigned()->nullable();
            $table->timestamps();
        });

        Schema::table('bacheca_has_contenuto', function (Blueprint $table) {
            $table->foreign('bacheca_id')->references('id')->on('bacheca')->onDelete('cascade');
            $table->foreign('contenuto_id')->references('id')->on('contenuto_bacheca')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('bacheca_has_contenuto');
    }
};
