<?php

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

class CreateOutcomeCriterionTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('outcome_criterion', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('outcome_id')->unsigned();
			$table->integer('criterion_id')->unsigned();
			$table->timestamps();
		});

		Schema::table('outcome_criterion', function(Blueprint $table)
		{
			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
			$table->foreign('criterion_id')->references('id')->on('criteria')->onDelete('cascade')->onUpdate('cascade');
		});
	}

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

}
