<?php

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

class CreateFacultySemesterTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('faculty_semester')) {
            Schema::create('faculty_semester', function (Blueprint $table) {
                $table->increments('id');
                $table->timestamps();

                $table->unsignedInteger('faculty_id');
                $table->unsignedInteger('semester_id');

                $table->foreign('faculty_id')->references('id')->on('faculties');
                $table->foreign('semester_id')->references('id')->on('semesters');
            });

        }
    }

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