<?php

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

class CreatePermissoesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permissoes', function (Blueprint $table) {
            $table->id();
            $table->string("permissao");
            $table->foreignId('sector_id');
            $table->foreignId('categoria_id');
            $table->softDeletes();
            $table->foreign('sector_id')->references('id')->on('sectores')->onDelete('cascade');
            $table->foreign('categoria_id')->references('id')->on('categorias')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {

        Schema::table('permissoes', function(Blueprint $table)
        {
            $table->dropSoftDeletes();
        });

        Schema::dropIfExists('permissoes');
    }
}

