<?php

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

class CreateJuriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('gestjury_jury', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->integer('id_filiere')->unsigned();
            $table->string('option')->nullable();
            $table->integer('president')->unsigned();
            $table->integer('maitre_memoire')->unsigned();
            $table->integer('membre_1')->unsigned();
            $table->integer('membre_2')->unsigned();
            $table->integer('id_etudiant')->unsigned();
            $table->string('sujet')->nullable();
            $table->integer('id_salle')->unsigned();
            $table->string('date')->nullable();
            $table->string('heure_debut')->nullable();
            $table->foreign('president')->references('id')->on('gestjury_membre_jury')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('maitre_memoire')->references('id')->on('gestjury_membre_jury')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('membre_1')->references('id')->on('gestjury_membre_jury')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('membre_2')->references('id')->on('gestjury_membre_jury')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('id_salle')->references('id')->on('gestjury_salle')->onDelete('cascade')->onUpdate('cascade');
        });
    }

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