<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDevicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('devices', function (Blueprint $table) {
            $table->id(); // Primary key
            $table->string('device_id')->unique(); // Unique identifier for the device
            $table->string('serial_number')->unique(); // Serial number of the device
            $table->string('module_number'); // Module's identification number
            $table->string('gps_location')->nullable(); // GPS coordinates (latitude, longitude)
            $table->ipAddress('local_ip_address')->nullable(); // Local IP address
            $table->string('mac_address')->unique(); // MAC address
            $table->enum('status', ['Active', 'Idle', 'Offline', 'Error'])->default('Idle'); // Current status
            $table->string('company_name'); // Name of the company or manufacturer
            $table->string('firmware_version')->default('v1.0.0'); // Firmware version
            $table->string('device_uptime')->nullable(); // Device uptime duration
            $table->string('battery_status')->nullable(); // Battery percentage or status
            $table->enum('network_type', ['Wi-Fi', 'Ethernet', 'Cellular'])->nullable(); // Network type
            $table->string('signal_strength')->nullable(); // Signal strength of the network
            $table->timestamp('time_synced')->nullable(); // Timestamp of last sync
            $table->timestamps(); // created_at and updated_at
        });
    }

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