<?php

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

class CreateOverlaysLangTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('overlays_lang', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('overlay_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->string('overlay_title', 150)->nullable();
            $table->text('content')->nullable();

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

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