<?php

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

class CreateProductDescriptionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('product_descriptions', function (Blueprint $table) {
            $table->id();
            $table->string('name', 300);
            $table->string('point_desc', 300)->nullable();
            $table->string('minimum_title', 300)->nullable();
            $table->string('maximum_title', 300)->nullable();
            $table->longText('description');
            $table->longText('advantages');
            $table->unsignedBigInteger('product_id')->index();
            $table->unsignedBigInteger('language_id')->index();

            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade')->onUpdate('cascade');
            $table->engine = 'InnoDB';
        });
    }

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