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