<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('blogs', function (Blueprint $table) {
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->id();
            $table->string('h1_en')->nullable();
            $table->string('h1_ar')->nullable();
            $table->string('title_en');
            $table->string('title_ar');
            $table->string('slug');
            $table->string('category_en')->nullable();
            $table->string('category_ar')->nullable();
            $table->text('tags_en')->nullable();
            $table->text('tags_ar')->nullable();
            $table->string('meta_title_en')->nullable();
            $table->string('meta_title_ar')->nullable();
            $table->text('meta_description_en')->nullable();
            $table->text('meta_description_ar')->nullable();
            $table->text('excerpt_en')->nullable();
            $table->text('excerpt_ar')->nullable();
            $table->longText('content_en');
            $table->longText('content_ar');
            $table->string('image')->nullable();
            $table->boolean('is_published')->default(false);
            $table->timestamp('published_at')->nullable();
            $table->timestamps();

            $table->unique('slug', 'blogs_slug_unique');
            $table->index('title_en', 'blogs_title_en_index');
            $table->index('title_ar', 'blogs_title_ar_index');
            $table->index('is_published', 'blogs_is_published_index');
            $table->index('published_at', 'blogs_published_at_index');
            $table->index('h1_en', 'blogs_h1_en_index');
            $table->index('h1_ar', 'blogs_h1_ar_index');
            $table->index('category_en', 'blogs_category_en_index');
            $table->index('category_ar', 'blogs_category_ar_index');
        });
    }

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