<?php

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

// The ai_costs.purpose column was an enum tied to the original purpose set
// (server_action, ticket_draft, ticket_classify, ...). The provider-resolver
// flow added five new purpose values (default, ticket_invest, server_chat,
// server_audit, anomaly_detect). Extend the enum to accept them — cost
// logging hits "Data truncated" otherwise.
return new class extends Migration {
    public function up(): void
    {
        DB::statement("ALTER TABLE ai_costs MODIFY COLUMN purpose ENUM(
            'server_action',
            'ticket_draft',
            'ticket_invest',
            'ticket_classify',
            'log_analysis',
            'scan_analysis',
            'cve_analysis',
            'image_analysis',
            'server_audit',
            'server_chat',
            'anomaly_detect',
            'default',
            'other'
        ) NOT NULL");
    }

    public function down(): void
    {
        DB::statement("ALTER TABLE ai_costs MODIFY COLUMN purpose ENUM(
            'server_action',
            'ticket_draft',
            'ticket_classify',
            'log_analysis',
            'scan_analysis',
            'cve_analysis',
            'image_analysis',
            'other'
        ) NOT NULL");
    }
};
