<?php

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

class OccurrencesLanguages extends Migration {

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

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

            $table->unique(['occurrence_id', 'language_id'], 'idx_occurrence_lang');
            $table->foreign('occurrence_id')->references('id')
                ->on('occurrences')->onDelete('CASCADE')->onUpdate('CASCADE');

        });
	}

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

}
