<?php

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

class AddProgramIdToCriteriaTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::table('criteria', function(Blueprint $table)
		{
			$table->integer('program_id')->after('user_id')->unsigned()->nullable();
			$table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::table('criteria', function(Blueprint $table)
		{
			$table->dropForeign('criteria_program_id_foreign');
			$table->dropColumn('program_id');
		});
	}

}
