<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ — NUCLEAR+++
// File: /migrations/030_usermeta_isolation.php
// Description: Migrate amai_setup_step and amai_autopilot_nudge_dismissed_at from wp_options to wp_usermeta - NUCLEAR+++
// Last Edited: 2026-05-10
// ==================================================
namespace AutoMarketerAI\Migrations;
defined('ABSPATH') || exit;
final class Migration_030_UsermetaIsolation
{
    public function up(): void
    {
        $primary_user_id = (int) get_option('amai_primary_user_id', 0);

        $setup_step = get_option('amai_setup_step');
        if ($setup_step !== false && $primary_user_id > 0) {
            update_user_meta($primary_user_id, 'amai_setup_step', (int) $setup_step);
        }
        delete_option('amai_setup_step');

        $dismissed_at = get_option('amai_autopilot_nudge_dismissed_at');
        if ($dismissed_at !== false && $primary_user_id > 0) {
            update_user_meta($primary_user_id, 'amai_autopilot_nudge_dismissed_at', (int) $dismissed_at);
        }
        delete_option('amai_autopilot_nudge_dismissed_at');
    }
}