<?php

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

class CreateOutcomePerformanceTable extends Migration
{

	public function up()
	{
		Schema::create('outcome_performance', function (Blueprint $table) {
			$table->increments('id');
			$table->integer('criterion_id')->unsigned();
			$table->integer('outcome_id')->unsigned();
			$table->integer('semester_id')->unsigned();
			$table->integer('students_attempted');
			$table->integer('students_achieved');
			$table->smallInteger('level');
			$table
				->foreign('criterion_id')
				->references('id')
				->on('criteria')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table
				->foreign('outcome_id')
				->references('id')
				->on('outcomes')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table
				->foreign('semester_id')
				->references('id')
				->on('semesters')
				->onDelete('cascade')
				->onUpdate('cascade');

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

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