<?php

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

class CreateAnnualPlansTable extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('annual_plans', function (Blueprint $table) {

			$table->increments('id');
			$table->string('academic_year');
			$table->integer('semester_start')->unsigned();
			$table->foreign('semester_start')
				->references('id')
				->on('semesters')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->integer('semester_end')->unsigned();
			$table->foreign('semester_end')
				->references('id')
				->on('semesters')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->integer('program_id')->unsigned();
			$table
				->foreign('program_id')
				->references('id')
				->on('programs')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->boolean('is_submitted')->default(0);
			$table->dateTime('submitted_on')->nullable();
			$table->timestamps();
		});
	}


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