<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('image_generations', function (Blueprint $table) {
            $table->text('original_prompt')->nullable()->after('user_id');
            $table->text('enhanced_prompt')->nullable()->after('original_prompt');
            $table->string('model', 64)->nullable()->after('aspect_ratio');
            $table->string('quality', 16)->nullable()->after('model');
        });

        DB::table('image_generations')->whereNull('original_prompt')->update([
            'original_prompt' => DB::raw('prompt'),
        ]);
    }

    public function down(): void
    {
        Schema::table('image_generations', function (Blueprint $table) {
            $table->dropColumn(['original_prompt', 'enhanced_prompt', 'model', 'quality']);
        });
    }
};
