<?php

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

class CreateAirportDescriptionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('airport_descriptions', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50);

            $table->unsignedBigInteger('airport_id');
            $table->unsignedBigInteger('language_id');

            $table->foreign('airport_id')->references('id')->on('airports')->onDelete('cascade');

            $table->index(['airport_id', 'language_id']);
            $table->engine = 'InnoDB';
        });
    }

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