<?php

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

class CreateTemplateCriterion extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('template_criterion', function (Blueprint $table) {
			$table->increments('id');
			$table->integer('template_id')->unsigned();
			$table->integer('criterion_id')->unsigned();
			$table->foreign('criterion_id')
				->references('id')
				->on('criteria')
				->onDelete('cascade')
				->onUpdate('cascade');
			$table->foreign('template_id')
				->references('id')
				->on('templates')
				->onDelete('cascade')
				->onUpdate('cascade');
		});
	}

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