<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('ai_writeups', function (Blueprint $table) {
            $table->id();
            $table->string('source');
            $table->string('source_url');
            $table->foreignId('category_id');
            $table->string('title');
            $table->string('editor_format');
            $table->mediumText('excerpt')->nullable();
            $table->string('featured_image')->nullable();
            $table->json('body')->nullable();
            $table->double('cost', 5, 5);
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories');
        });
    }

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