<?php

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

/**
 * The message id is the provider's, not ours, so we do not get to size it.
 *
 * It was 36 because a uuid is 36. The value is whatever the model provider
 * issues, and OpenAI's is 53 characters, so the first real turn on MySQL failed
 * with "Data too long for column 'created_by_message_id'" and the campaign was
 * never created. Sqlite ignores column widths, so nothing caught it until the
 * database changed underneath.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('conversation_artifacts', function (Blueprint $table): void {
            $table->string('created_by_message_id', 255)->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('conversation_artifacts', function (Blueprint $table): void {
            $table->string('created_by_message_id', 36)->nullable()->change();
        });
    }
};
