<?php

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

class CreateDispositivosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('dispositivos', function (Blueprint $table) {
            $table->id();
            $table->string('countryName');
            $table->string('countryCode');
            $table->string('regionCode');
            $table->string('regionName');
            $table->string('cityName');
            $table->string('latitude');
            $table->string('longitude');
            $table->string('browser');
            $table->string('versaoBrowser');
            $table->string('plataform');
            $table->string('versaoPlataform');
            $table->string('device');
            $table->string('robot');
            $table->string('ip');
            $table->string('mac');
            $table->enum('estado',['null','barrado','solicitado','permitido']);
            $table->unsignedBigInteger('user_id');
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('dispositivos', function(Blueprint $table)
        {
            $table->dropSoftDeletes();
        });
        Schema::dropIfExists('dispositivos');
    }
}
