<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ — NUCLEAR+++
// File: /migrations/021_abandoned_carts_raw_total.php
// Description: Add cart_total_raw float column to wp_amai_abandoned_carts - NUCLEAR+++
// Last Edited: 2026-04-21
// ==================================================

namespace AutoMarketerAI\Migrations;

defined('ABSPATH') || exit;

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

        $col = $wpdb->get_results(
            "SHOW COLUMNS FROM `{$table}` LIKE 'cart_total_raw'",
            ARRAY_A
        );

        if (!empty($col)) {
            return;
        }

        $wpdb->query(
            "ALTER TABLE `{$table}` ADD COLUMN `cart_total_raw` DECIMAL(10,2) NULL DEFAULT NULL AFTER `cart_total`"
        );
    }
}