<?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()
    {
        $tableName = config('laravel-device-tracking.device_table');
        Schema::create($tableName, function (Blueprint $table) {
            $table->id();
            $table->string('device_uuid')->unique();
            $table->string('device_type')->index();
            $table->string('ip',40)->index();

            $table->timestamp('device_hijacked_at')->nullable();

            $table->json('data',60)->nullable();
            $table->boolean('is_rogue_device')->default(false)->index();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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