<?php

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

class CreateEventItemLanguagesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('event_item_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('event_item_id');
            $table->string('language_id', 10);

            $table->string('title', 150);
            $table->string('location', 255)->nullable();
            $table->string('contact_details', 255)->nullable();
            $table->text('cta')->nullable();

            // Languages
            $table->unique(['event_item_id', 'language_id'], 'idx_event_item_language');
            $table->foreign('event_item_id')
                ->references('id')
                ->on('event_items')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
	}

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

}
