<?php

declare(strict_types=1);

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('creator_ai_biographies', function (Blueprint $table): void {
            $table->id();
            $table->unsignedBigInteger('user_id')->index();
            $table->text('text')->nullable();
            $table->string('source_hash', 64)->nullable()->index();
            $table->string('model', 120)->nullable();
            $table->string('status', 30)->default('generated'); // generated|approved|edited|hidden|failed
            $table->boolean('is_active')->default(false)->index();
            $table->boolean('is_hidden')->default(false);
            $table->boolean('is_user_edited')->default(false);
            $table->timestamp('generated_at')->nullable();
            $table->timestamp('approved_at')->nullable();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
        });
    }

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