<?php

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

class CreateObjectivesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('objectives', function(Blueprint $table)
		{
			$table->engine = 'InnoDB';
			$table->increments('id');
			$table->integer('outcome_id')->unsigned();
			$table
				->foreign('outcome_id')
				->references('id')
				->on('outcomes')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->integer('program_id')->unsigned();
			$table
				->foreign('program_id')
				->references('id')
				->on('programs')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->string('text');
			$table->unique(array('outcome_id', 'program_id', 'text'));
			$table->timestamps();
		});
	}


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

}
