<?php

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

class CreateSliderDescriptionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('slider_descriptions', function (Blueprint $table) {
            $table->id();
            $table->string('title', 300);
            $table->longText('description');

            $table->unsignedBigInteger('slider_id')->index();
            $table->unsignedBigInteger('language_id')->index();

            $table->foreign('slider_id')->references('id')->on('sliders')->onDelete('cascade')->cascadeOnDelete();
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade')->cascadeOnDelete();

            $table->engine = 'InnoDB';
        });
    }

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