<?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('dispositivo', function (Blueprint $table) {
            $table->id();
            $table->string('nome');
            $table->string('licenza');
            $table->string('url_stampante')->nullable();
            $table->string('ubicazione')->nullable();
            $table->string('note')->nullable();
            $table->string('tipo')->nullable();
            $table->boolean('is_attivo')->default(true);
            $table->string('pin_sblocco')->nullable();
            $table->string('binding_token')->nullable();
            $table->dateTime('data_apertura_dispositivo')->nullable();
            $table->dateTime('data_chiusura_dispositivo')->nullable();
            $table->timestamps();
        });

        Schema::table('cucina', function (Blueprint $table) {
            $table->foreign('stampante_id')->references('id')->on('dispositivo')->onDelete('set null');
        });
    }

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