<?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
    {
        if (!Schema::hasTable('wa_conversations') || Schema::hasColumn('wa_conversations', 'labels')) {
            return;
        }

        Schema::table('wa_conversations', function (Blueprint $table) {
            $table->json('labels')->nullable()->after('status');
        });
    }

    public function down(): void
    {
        if (Schema::hasTable('wa_conversations') && Schema::hasColumn('wa_conversations', 'labels')) {
            Schema::table('wa_conversations', function (Blueprint $table) {
                $table->dropColumn('labels');
            });
        }
    }
};
