<?php

declare(strict_types=1);

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

/**
 * Editable content pages: studio rules, terms, privacy, FAQ.
 *
 * The studio rules were promised "later", and terms and privacy will need
 * revising the first time a solicitor reads them. None of that should be a
 * deployment — so the text lives in the database and is edited in the admin
 * panel rather than being hard-coded into Blade.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('pages', function (Blueprint $table) {
            $table->id();
            $table->string('slug')->unique();
            $table->string('title');
            $table->string('summary')->nullable();
            $table->longText('body')->nullable();

            $table->boolean('is_published')->default(false);
            $table->boolean('show_in_footer')->default(false);
            $table->unsignedSmallInteger('sort_order')->default(0);
            $table->timestamps();

            $table->index(['is_published', 'sort_order']);
        });
    }

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