<?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('flux_cms_pages', function (Blueprint $table) {
            $table->id();
            $table->string('domain_key')->index();
            $table->json('title'); // Übersetzbarer Seitentitel
            $table->json('meta_description')->nullable(); // SEO Meta Description
            $table->json('meta_keywords')->nullable(); // SEO Keywords
            $table->json('og_image')->nullable(); // Open Graph Image (Media Library Reference)
            $table->string('canonical_url')->nullable(); // SEO Canonical URL
            $table->json('settings')->nullable(); // Zusätzliche Einstellungen
            $table->boolean('is_published')->default(true);
            $table->timestamp('published_at')->nullable();
            $table->timestamps();

            // Composite indexes for performance
            $table->index(['domain_key', 'is_published']);
            $table->index(['domain_key', 'is_published', 'published_at']);
        });
    }

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