<?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('impostazioni', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('attivita_id')->unsigned()->nullable();
            $table->string('gruppo')->nullable();
            $table->string('chiave')->nullable();
            $table->string('label')->nullable();
            $table->text('descrizione')->nullable();
            $table->string('tipo')->nullable();
            $table->string('valore')->nullable();
            $table->json('opzioni')->nullable();
            $table->timestamps();
        });
        Schema::table('impostazioni', function (Blueprint $table) {
            $table->foreign('attivita_id')->references('id')->on('attivita')->onDelete('set null');
        });
    }

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