<?php

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

class CreateCountriesLang extends Migration
{

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

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

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

}
