<?php

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


class CreateDocsUtilesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('docs_utiles', function (Blueprint $table) {
            $table->id();
            $table->string('nom');
            $table->text('description');
            $table->text('url');
            $table->unsignedBigInteger('user_matricule')->nullable(false);
            $table->unsignedBigInteger('categorie_id')->nullable(false);
            $table->foreign('categorie_id')->references('id')->on('categories_docs_utiles')->onDelete('cascade');
            $table->unsignedBigInteger('departement_id')->nullable(false);
            $table->enum('statut', ['PUBLISHED', 'PENDING', 'BLOCKED', 'SIGNALED', 'DELETED'])->default('PUBLISHED');
            $table->dateTime('created_at')->nullable(false)->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->dateTime('updated_at')->nullable(false)->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
    }

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