<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateInfographicsLangTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('infographics_lang', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('infographic_id');
            $table->string('language_id', 10);
            $table->string('title', 150)->nullable();
            $table->mediumText('content')->nullable();

            $table->unique(['infographic_id', 'language_id'], 'idx_infographic_lang');

            $table->foreign('infographic_id')->references('id')
                ->on('infographics')->onDelete('CASCADE')->onUpdate('CASCADE');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('infographics_lang');
    }
}
