<?php

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

class CreateVideoTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('videos', function (Blueprint $table) {
            $table->id();
            $table->string('video', 300)->nullable();
            $table->string('image', 200)->nullable();
            $table->enum('type', [1,2])->nullable()->comment('1-> Youtube video file, 2-> localfile');

            $table->unsignedBigInteger('video_category_id')->nullable();

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

            $table->timestamps();
            $table->softDeletes();

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

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