<?php

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

class CreateTestimonialDescriptionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('testimonial_descriptions', function (Blueprint $table) {
            $table->id();
            $table->string('name',50);
            $table->string('job_title',100);
            $table->string('comment',500);
            $table->unsignedBigInteger('testimonial_id');
            $table->unsignedBigInteger('language_id');
            $table->foreign('testimonial_id')->references('id')->on('testimonials')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade')->onUpdate('cascade');
            $table->index(['testimonial_id', 'language_id']);

            // Set engine to InnoDB it's useful in join and constraint
            $table->engine = 'InnoDB';
        });
    }

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