<?php

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

class CreateIQContentFilesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('i_q_content_files', function (Blueprint $table) {

            $table->bigIncrements('id');
            $table->unsignedBigInteger('folder_id')->nullable()->index();

            $table->string('name')->index();
            $table->string('identifier')->nullable();
            $table->string('slug')->unique()->index();

            $table->string('ext', 10)->nullable();
            $table->string('mine', 100)->nullable();
            $table->unsignedInteger('size')->unsigned();
            $table->string('dimensions', 100)->nullable();

            $table->text('content')->nullable();

            $table->unsignedTinyInteger('color')->default(0);
            $table->unsignedTinyInteger('pos')->default(0);
            $table->boolean('active')->default(true);

            $table->timestamps();

            $table->foreign('folder_id')
                ->references('id')
                ->on('i_q_content_folders')
                ->onDelete('cascade');
        });
    }

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

