<?php

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

class CreateObjectiveOutcomeTable extends Migration
{

	public function up()
	{
		Schema::create('objective_outcome', function (Blueprint $table) {
			$table->increments('id');

			$table->integer('objective_id')->unsigned();
			$table
				->foreign('objective_id')
				->references('id')
				->on('objectives')
				->onDelete('cascade')
				->onUpdate('cascade');

			$table->integer('outcome_id')->unsigned();
			$table
				->foreign('outcome_id')
				->references('id')
				->on('outcomes')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->timestamps();
			$table->unique(array('objective_id', 'outcome_id'));
		});
	}


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