<?php

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

class CreateAcademicFormationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('academic_formations', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unsigned();
            $table->string('institution_name');
            $table->tinyInteger('educational_level_id')->unsigned()->nullable();
            $table->string('study_area')->nullable();
            $table->enum('status',['1','2','3']);
            $table->enum('modality', ['1','2','3'])->default('1');

            $table->enum('initial_date_month', ['1','2','3','4','5','6','7','8','9','10','11','12'])->nullable();
            $table->string('initial_date_year',4);
            $table->enum('final_date_month', ['1','2','3','4','5','6','7','8','9','10','11','12'])->nullable();
            $table->string('final_date_year',4)->nullable();
            $table->string('academic_formation_support', 255)->nullable();
            $table->string('professional_card_support', 255)->nullable();

            $table->foreign('user_id')->references('id')->on('users')
            ->onDelete('cascade')
            ->onUpdate('cascade');
            $table->foreign('educational_level_id')->references('id')->on('educational_levels')
            ->onDelete('cascade')
            ->onUpdate('cascade');

            $table->timestamps();
        });
    }

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