<?php

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

class CreateMeetingLanguagesTable extends Migration {

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

            $table->string('title', 150);

            $table->text('location')->nullable();
            $table->text('contact_details')->nullable();
            $table->text('cta')->nullable();

            // Languages
            $table->unique(['meeting_id', 'language_id'], 'idx_meeting_language');
            $table->foreign('meeting_id')
                ->references('id')
                ->on('meetings')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
	}

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

}
