<?php

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

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

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

            $table->foreign('purpose_training_id')->references('id')->on('purpose_trainings')->onDelete('cascade');

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

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