<?php

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

class CreateProfessorSectionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('professor_section', function (Blueprint $table) {
            $table->unsignedBigInteger('professor_id');
            $table->unsignedBigInteger('section_id');
            $table->unsignedInteger('percent')->nullable();
            $table->string('schedule')->nullable();
            $table->float('eval')->nullable();

            $table->foreign('professor_id')->references('id')->on('professors');
            $table->foreign('section_id')->references('id')->on('sections');

            $table->unique(['professor_id', 'section_id']);
        });
    }

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