<?php

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

class CreateAcessosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('acessos', function (Blueprint $table) {
            $table->id();
            $table->enum('estado',['fracasso','sucesso'])->comment('sucesso ao acessar ou fracasso no mesmo, identificando uma tentativa falhada');
            $table->enum('sessao',['fechada','aberta']);
            $table->unsignedBigInteger('dispositivo_id');
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('dispositivo_id')->references('id')->on('dispositivos')->onDelete('cascade')->onUpdate('cascade');
        });
    }

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