<?php

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

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

            $table->id();
            $table->string('name',100);
            $table->string('slug',100);
            $table->string('keywords',400);
            $table->text('meta_description');

            $table->bigInteger('video_category_id')->unsigned()->nullable();
            $table->bigInteger('language_id')->unsigned()->nullable();

            $table->foreign('video_category_id')->references('id')->on('video_categories')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');

            $table->index(['video_category_id', 'language_id']);

            // $table->timestamps(); No Need as it is joined to Categories table so any update or delete will affect here

            // For transaction and join constrians
            $table->engine = 'InnoDB';
        });
    }

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