<?php

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

class CreateBlockAgendaItemsLangTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('block_agenda_items_lang', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('block_agenda_item_id');
            $table->string('language_id', 10);
            $table->string('title', 255);
            $table->text('content')->nullable();
            $table->string('time_label', 150)->nullable();
            $table->string('speakers_label', 150)->nullable();

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

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