<?php

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

class StoriesLanguage extends Migration {

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

            $table->string('meta_title', 150)->nullable();
            $table->string('meta_description', 300)->nullable();

            $table->unique(['story_id', 'language_id'], 'idx_story_lang');

            $table->foreign('story_id')->references('id')
                ->on('stories')->onDelete('CASCADE')->onUpdate('CASCADE');

        });
	}

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

}
