<?php

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

class CreateTemplatesTable extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('templates', function (Blueprint $table) {
			$table->increments('id');
			$table->string('name');

			$table->timestamps();
			$table->integer('school_id')->unsigned()->nullable();
			$table
				->foreign('school_id')
				->references('id')
				->on('schools')
				->onDelete('cascade')
				->onUpdate('cascade');

			$table->integer('program_id')->unsigned()->nullable();
			$table->foreign('program_id')->references('id')->on('programs');
			$table->boolean('is_visible')->default(false);
			$table->integer('expected_percentage')->default(70);
			$table->integer('expected_points')->default(5);
			$table->integer('num_scales')->unsigned();
			$table->integer('max_score')->unsigned();
		});
	}

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