<?php

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

class BlocksLanguages extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('block_languages', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('block_id');
            $table->string('language_id', 10);
            $table->string('title', 150);

            $table->string('block_title', 300)->nullable();
            $table->string('block_subtitle', 300)->nullable();
            $table->text('block_description', 1200)->nullable();
            $table->string('block_cta', 150)->nullable();

            $table->unique(['block_id', 'language_id'], 'idx_block_lang');
            $table->foreign('block_id')->references('id')
                ->on('blocks')->onDelete('CASCADE')->onUpdate('CASCADE');

        });
	}

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

}
