<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ — NUCLEAR+++
// File: /migrations/011_post_stats.php
// Description: Add stat columns to wp_amai_scheduled_posts for post performance tracking - NUCLEAR+++
// Last Edited: 2026-04-10
// ==================================================
namespace AutoMarketerAI\Migrations;
defined('ABSPATH') || exit;
final class Migration_011_PostStats
{
    public const VERSION     = '011';
    public const DESCRIPTION = 'Add stat columns to wp_amai_scheduled_posts';
    public function up(): void
    {
        global $wpdb;
        $table = $wpdb->prefix . 'amai_scheduled_posts';
        $exists = $wpdb->get_results(
            "SHOW COLUMNS FROM `{$table}` LIKE 'stat_likes'"
        );
        if (empty($exists)) {
            $wpdb->query(
                "ALTER TABLE `{$table}`
                 ADD COLUMN `stat_likes`       INT      NULL DEFAULT NULL,
                 ADD COLUMN `stat_comments`    INT      NULL DEFAULT NULL,
                 ADD COLUMN `stat_reach`       INT      NULL DEFAULT NULL,
                 ADD COLUMN `stats_fetched_at` DATETIME NULL DEFAULT NULL"
            );
        }
    }
}
