<?php

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::table('blog_posts', function (Blueprint $table) {
            // Drop the JSON check constraint if it exists
            DB::statement('ALTER TABLE blog_posts DROP CONSTRAINT IF EXISTS blog_posts_content_check');
            
            // Change content column from JSON to longText for HTML storage
            $table->longText('content')->nullable()->change();
        });
    }

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