<?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('academy_prompt_templates', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('category_id')->nullable()->constrained('academy_categories')->nullOnDelete();
            $table->string('title');
            $table->string('slug')->unique();
            $table->text('excerpt')->nullable();
            $table->longText('prompt');
            $table->longText('negative_prompt')->nullable();
            $table->longText('usage_notes')->nullable();
            $table->longText('workflow_notes')->nullable();
            $table->string('difficulty')->default('beginner');
            $table->string('access_level')->default('free');
            $table->string('aspect_ratio')->nullable();
            $table->json('tags')->nullable();
            $table->json('tool_notes')->nullable();
            $table->string('preview_image')->nullable();
            $table->boolean('featured')->default(false);
            $table->boolean('prompt_of_week')->default(false);
            $table->boolean('active')->default(true);
            $table->timestamp('published_at')->nullable();
            $table->string('seo_title')->nullable();
            $table->text('seo_description')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->index(['active', 'featured', 'access_level']);
            $table->index(['prompt_of_week', 'active']);
        });
    }

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