<?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('devices', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('entity_type')->default('DEVICE');
            $table->bigInteger('created_time');
            $table->uuid('tenant_id');
            $table->uuid('customer_id');
            $table->uuid('asset_id');
            $table->string('name');
            $table->string('type');
            $table->string('label')->nullable();
            $table->uuid('device_profile_id');
            $table->uuid('firmware_id')->nullable();
            $table->uuid('software_id')->nullable();
            $table->uuid('external_id')->nullable();
            $table->integer('version')->default(1);
            $table->smallInteger('active')->default(1)->comment('1: Active, 0: Inactive');
            $table->json('additional_info')->nullable();
            $table->json('device_data')->nullable();
            $table->timestamps();

            // $table->foreign('tenant_id')->references('id')->on('tenants');
            // $table->foreign('customer_id')->references('id')->on('customers');
            // $table->foreign('asset_id')->references('id')->on('assets');

        });
    }

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