<?php

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

class CreateTasksTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('tasks', function(Blueprint $table)
		{
			$table->bigIncrements('id');
			$table->string('title', 128);
			$table->text('problem')->nullable();
			$table->unsignedBigInteger('client_id');
			$table->enum('client_type', array('customer', 'client'))->default('customer');
			$table->unsignedBigInteger('site_id')->nullable();
			$table->unsignedBigInteger('site_user_id')->nullable();
			$table->string('direct_dial', 32)->nullable();
			$table->unsignedBigInteger('created_by');
			$table->unsignedBigInteger('assigned_to');
			$table->unsignedBigInteger('status');
			$table->integer('time_spent')->default(0);
			$table->unsignedBigInteger('severity');
			$table->enum('type', array('repair', 'support', 'onsite', 'order'))->default('repair');
			$table->unsignedBigInteger('project_id')->nullable();
			$table->boolean('prebook')->default(false);
			$table->timestamp('prebook_date')->nullable();
			$table->timestamp('onsite_start')->nullable();
			$table->timestamp('onsite_end')->nullable();
			$table->timestamps();
		});
	}

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

}
