<?php

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

class CreateCollectionLanguagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        Schema::create('collection_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('collection_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->text('description')->nullable();
            $table->string('image_label', 150);

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

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