<?php

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

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

            $table->bigIncrements('id');

            $table->unsignedBigInteger('file_id')->index();
            $table->unsignedBigInteger('tag_id')->index();

            $table->timestamps();

            $table->foreign('file_id')
                ->references('id')
                ->on('i_q_content_files')
                ->onDelete('cascade');

            $table->foreign('tag_id')
                ->references('id')
                ->on('i_q_content_tags')
                ->onDelete('cascade');


        });
    }

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

