<?php

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

class CreatePropertyLanguages extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('property_id');
            $table->string('language_id', 10);

            $table->string('title', 255);
            $table->text('description')->nullable();
            $table->text('reading_suggestion')->nullable();
            $table->mediumText('plunder_locations')->nullable();

            // Date
            $table->dateTime('last_update')->nullable();

            // Metas
            $table->string('meta_title', 150)->nullable();
            $table->string('meta_description', 300)->nullable();

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

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

}
