<?php

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

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

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

            $table->foreign('package_id')->references('id')->on('packages')->onDelete('cascade');

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

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