<?php

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

class CreateAttachmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attachments', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();

            $table->string('filename')->nullable();
            $table->string('path')->nullable();
            $table->integer('task_id')->nullable()->unsigned();
            $table->string('original_name')->nullable();
            $table->integer('user_id')->nullable()->unsigned();
            $table->integer('subtask_id')->nullable()->unsigned();
            $table->string('mimetype')->nullable();
            $table->integer('delivered')->nullable()->default(0);

            $table->foreign('task_id')->references('id')->on('tasks')->onDelete('set null');
            $table->foreign('subtask_id')->references('id')->on('subtasks')->onDelete('set null');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');



        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
