<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ -- NUCLEAR+++
// File: /home/ploi/automarketer-ai.com/public/wp-content/plugins/automarketer-ai/migrations/046_comment_sentiment.php
// Description: Adds sentiment and sentiment_score columns to wp_amai_social_comments - NUCLEAR+++
// Last Edited: 2026-05-20
// ==================================================
namespace AutoMarketerAI\Migrations;
defined('ABSPATH') || exit;

class Migration_046_CommentSentiment
{
    public function up(): void
    {
        global $wpdb;
        $table = $wpdb->prefix . 'amai_social_comments';

        $cols = $wpdb->get_col("DESCRIBE `{$table}`");
        if (!is_array($cols)) {
            return;
        }

        if (!in_array('sentiment', $cols, true)) {
            $wpdb->query(
                "ALTER TABLE `{$table}`
                 ADD COLUMN `sentiment` ENUM('positive','neutral','negative','unscored') NOT NULL DEFAULT 'unscored'
                 AFTER `is_followup`"
            );
        }

        if (!in_array('sentiment_score', $cols, true)) {
            $wpdb->query(
                "ALTER TABLE `{$table}`
                 ADD COLUMN `sentiment_score` TINYINT(4) DEFAULT NULL
                 AFTER `sentiment`"
            );
        }
    }
}