<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('website_objects_lang', function (Blueprint $table) {
            $table->bigIncrements('wo_translation_id');
            $table->unsignedBigInteger('website_object_id');
            $table->string('wo_language_id', 10);
            $table->string('slug', 255)->nullable();
            $table->string('uri', 300)->nullable();
            $table->string('status', 20)->nullable();
            $table->string('meta_title', 150)->nullable();
            $table->string('meta_description', 300)->nullable();

            $table->unique(['website_object_id', 'wo_language_id'], 'idx_objects_lang_unique');
            $table->index(['wo_language_id', 'slug'], 'idx_objects_slug_unique');

            $table->unique(['wo_language_id', 'uri'], 'wo_uri_index');

            $table->foreign('website_object_id')->references('website_object_id')
                ->on('website_objects')->onDelete('CASCADE')->onUpdate('RESTRICT');
        });
    }

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