<?php

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

class CreateFormLanguagesTable extends Migration
{
    public function up()
    {
        Schema::create('form_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('form_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->text('description')->nullable();

            $table->unique(['form_id', 'language_id'], 'idx_form_lang');
            $table->foreign('form_id')
                ->references('id')
                ->on('forms')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
    }

    public function down()
    {
        Schema::dropIfExists('form_languages');
    }
}
