<?php

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

class CreateExhibitionLanguages extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('exhibition_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('exhibition_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->text('description')->nullable();
            $table->string('press_release_link', 255)->nullable();

            // Languages
            $table->unique(['exhibition_id', 'language_id'], 'idx_exhibition_lang');
            $table->foreign('exhibition_id')
                ->references('id')
                ->on('exhibitions')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
	}

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

}
