<?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('fatturazione', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->nullable()->unsigned();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->bigInteger('attivita_id')->nullable()->unsigned();
            $table->foreign('attivita_id')->references('id')->on('attivita')->onDelete('set null');
            $table->bigInteger('dispositivo_id')->nullable()->unsigned();
            $table->foreign('dispositivo_id')->references('id')->on('dispositivo')->onDelete('set null');
            $table->string('tipo_dispositivo')->nullable();
            $table->integer('ordini')->nullable();
            $table->decimal('prezzo', 10, 2)->nullable();
            $table->string('stato')->nullable();
            $table->string('note')->nullable();
            $table->string('path_pdf')->nullable();
            $table->string('path_xml')->nullable();
            $table->json('metadata')->nullable();
            $table->timestamps();
        });
    }

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