<?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::table('monitor_has_contenuto', function (Blueprint $table) {
            $table->bigInteger('bacheca_id')->unsigned()->nullable()->after('contenuto_bacheca_id');
            $table->foreign('bacheca_id')->references('id')->on('bacheca')->onDelete('set null');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('monitor_has_contenuto', function (Blueprint $table) {
            $table->dropForeign(['bacheca_id']);
            $table->dropColumn('bacheca_id');
        });
    }
};
