<?php

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

class CreateFypPartsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('fyp_parts', function(Blueprint $table)
		{
			$table->engine = 'InnoDB';
			$table->increments('id');
			$table->integer('five_year_plan_id')->unsigned();
			$table
				->foreign('five_year_plan_id')
				->references('id')
				->on('five_year_plans')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->char('year_start', 4);
			$table->char('year_end', 4);
			$table->timestamps();
		});

		DB::statement("ALTER TABLE `fyp_parts` comment 'Annual plans that are part of a five-year plan'");
	}


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

}
