<?php

use Illuminate\Support\Facades\Schema;
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->increments('id');
            $table->timestamps();

            $table->boolean('draft')->nullable();
            $table->string('type')->nullable();

            $table->string('title')->nullable();
            $table->text('description')->nullable();
            $table->date('deadline')->nullable();
            $table->integer('profile_id')->nullable()->unsigned();

            $table->integer('status_id')->nullable()->unsigned();
            $table->integer('user_id')->nullable()->unsigned();

            $table->integer('taskdata_id')->nullable()->unsigned();



            $table->integer('unit_id')->nullable()->unsigned();

            $table->string('pipelineRevision')->nullable();
            $table->integer('reassignTask')->nullable();

            $table->foreign('unit_id')->references('id')->on('units')->onDelete('set null');


           $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
           $table->foreign('status_id')->references('id')->on('status')->onDelete('set null');


           $table->foreign('profile_id')->references('id')->on('profiles')->onDelete('set null');

           $table->foreign('taskdata_id')->references('id')->on('taskdata')->onDelete('cascade');

        });
    }

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