<?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('territori', function (Blueprint $table) {
            $table->id();
            $table->string('numero')->unique();
            $table->foreignId('zona_id')->nullable()->constrained('zone')->nullOnDelete();
            $table->foreignId('tipologia_id')->nullable()->constrained('tipologie')->nullOnDelete();
            $table->text('note')->nullable();
            $table->text('confini')->nullable();
            $table->string('pdf_path')->nullable();
            $table->boolean('attivo')->default(true);
            $table->boolean('prioritario')->default(false);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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