<?php

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

class CreatePermissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permissions', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('folder_id')->index('permissions_folder_id_foreign');
            $table->unsignedBigInteger('user_id')->nullable()->index('permissions_user_id_foreign');
            $table->tinyInteger('can_create_folder')->default(0);
            $table->tinyInteger('can_update_folder')->default(0);
            $table->tinyInteger('can_delete_folder')->default(0);
            $table->tinyInteger('can_create_document')->default(0);
            $table->tinyInteger('can_delete_document')->default(0);
            $table->timestamps();
        });
    }

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