Jake Vanderwerf
2026-01-19 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367
inc/registry/CheckCustomTables.php
@@ -44,25 +44,6 @@
      $this->userIDType = $this->getColumnType($this->userTable, 'ID');
      $this->termIDType = $this->getColumnType($this->wpdb->terms, 'term_id');
      $this->postIDType = $this->getColumnType($this->wpdb->posts, 'ID');
      error_log("JVB DEBUG: userTable = " . $this->userTable);
      error_log("JVB DEBUG: Users table exists = " . ($this->wpdb->get_var("SHOW TABLES LIKE '{$this->userTable}'") ? 'yes' : 'no'));
      error_log("JVB DEBUG: Users engine = " . $this->wpdb->get_var("SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{$this->userTable}'"));
      error_log("JVB DEBUG: MySQL version = " . $this->wpdb->db_version());
      $usersStatus = $this->wpdb->get_row("SHOW TABLE STATUS LIKE '{$this->userTable}'");
      $termsStatus = $this->wpdb->get_row("SHOW TABLE STATUS LIKE '{$this->wpdb->terms}'");
      error_log("JVB DEBUG: wp_users collation = " . $usersStatus->Collation);
      error_log("JVB DEBUG: wp_terms collation = " . $termsStatus->Collation);
      error_log("JVB DEBUG: Our charset_collate = " . $this->wpdb->get_charset_collate());
      error_log("JVB FK Types: users.ID={$this->userIDType}, terms.term_id={$this->termIDType}, posts.ID={$this->postIDType}");
      $usersDb = $this->wpdb->get_var(
         "SELECT TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{$this->userTable}' LIMIT 1"
      );
      error_log("JVB DEBUG: wp_users is in database = " . $usersDb);
      error_log("JVB DEBUG: Current DB_NAME = " . DB_NAME);
      error_log("JVB DEBUG: Tables being created in = " . $this->wpdb->dbname);
   }
   protected function getMultisiteUsersTable():string
@@ -463,34 +444,41 @@
            `id` VARCHAR(64) NOT NULL,
            `type` varchar(50) NOT NULL,
            `user_id` {$this->userIDType} NOT NULL,
            `request_data` JSON NOT NULL,
            `count` int(11) NOT NULL DEFAULT 1,
            `progress_count` int(11) DEFAULT 0,
            `total_items` int(11) NOT NULL DEFAULT 1,
            `processed_items` int(11) DEFAULT 0,
            `failed_items` JSON,
            `priority` enum('low', 'normal', 'high') DEFAULT 'normal',
            `status` enum('pending', 'scheduled', 'processing','failed', 'failed_permanent', 'completed', 'completed_with_errors') DEFAULT 'pending',
            `metadata` JSON DEFAULT NULL,
            `merge` enum('merge', 'append', 'replace') DEFAULT 'merge',
            `scheduled_at` datetime DEFAULT CURRENT_TIMESTAMP,
            `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
            `updated_at` datetime DEFAULT CURRENT_TIMESTAMP,
            `started_at` datetime DEFAULT NULL,
//            `status` enum('pending', 'scheduled', 'processing','failed', 'failed_permanent', 'completed', 'completed_with_errors') DEFAULT 'pending',
            `state` enum('pending', 'scheduled', 'processing', 'completed'),
            `outcome` enum('success', 'partial', 'failed','failed_permanent'),
         `retries` int(11) DEFAULT 0,
            `last_error_hash` CHAR(32) DEFAULT NULL,
            `error_message` text,
         `scheduled_at` datetime DEFAULT CURRENT_TIMESTAMP,
            `started_at` datetime DEFAULT CURRENT_TIMESTAMP,
            `completed_at` datetime DEFAULT NULL,
            `retries` int(11) DEFAULT 0,
            `metadata` JSON DEFAULT NULL,
            `result` JSON,
            `dependencies` JSON,
            `error_message` text,
//            `merge` enum('merge', 'append', 'replace') DEFAULT 'merge',
            `user_dismissed` tinyint(1) DEFAULT 0,
                PRIMARY KEY (`id`),
                KEY `idx_status_priority` (`status`, `priority`),
                KEY `idx_user_type` (`user_id`, `type`),
                KEY `idx_created_at` (`created_at`),
                KEY `idx_completed_at` (`completed_at`),
                KEY `idx_user_status` (`user_id`, `status`),
                KEY `idx_retries_status` (`retries`, `status`),
                KEY `idx_user_status_created` (`user_id`, `status`, `created_at`),
                KEY `idx_scheduled_processing` (`scheduled_at`, `status`)
            `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
         `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
         PRIMARY KEY (`id`),
            KEY `idx_run_queue` (state, priority, scheduled_at),
         KEY `idx_user_ops` (user_id, state),
         KEY `idx_user_type_pending` (user_id, type, state),
         KEY `idx_completed_at` (completed_at)
            )",
      'stats__operation_queue' => "(
            `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
            `date` date NOT NULL,