<?php

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

/**
 * Upgrade legacy TEXT columns to MEDIUMTEXT so large imported comments
 * (incl. spam-heavy legacy rows) do not cause truncation errors.
 *
 * TEXT      = 65,535 bytes   (~64 KB)
 * MEDIUMTEXT = 16,777,215 bytes (~16 MB)
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('artwork_comments', function (Blueprint $table) {
            $table->mediumText('content')->nullable()->change();
        });

        Schema::table('forum_posts', function (Blueprint $table) {
            $table->mediumText('content')->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('artwork_comments', function (Blueprint $table) {
            $table->text('content')->nullable()->change();
        });

        Schema::table('forum_posts', function (Blueprint $table) {
            $table->text('content')->nullable()->change();
        });
    }
};
