<?php

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

class CreateNewCriteriaTable extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('criteria', function (Blueprint $table) {
			$table->increments('id');
			$table->string('name');
			$table->string('subcriteria')->nullable();
			$table->text('description12');
			$table->text('description34');
			$table->text('description56');
			$table->text('description78');
			$table->integer('objective_id')->unsigned();
			$table->integer('program_id')->unsigned()->nullable();
			$table->integer('user_id')->unsigned()->nullable();
			$table->text('copyright')->nullable();
			$table->text('notes')->nullable();

			$table->timestamps();
			$table->timestamp('deleted_at')->nullable();

			$table->foreign('objective_id')->references('id')->on('objectives')->onDelete('cascade')->onUpdate('cascade');
			$table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
			$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
		});
	}


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