<?php

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

class AddProgramIdToTemplatesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::table('templates', function(Blueprint $table)
		{
			$table->integer('program_id')->unsigned()->nullable();
		});

		Schema::table('templates', function(Blueprint $table)
		{
			$table->foreign('program_id')->references('id')->on('programs');
		});
	}


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

}
