-- Explicit maintenance upgrade of the unreleased gold addon v1. Preserve all -- intents/receipts; do not invent a closed source for an old held actor. Stop -- producers and matched game/DB first, then restart after verification. DELIMITER // DROP PROCEDURE IF EXISTS port_cube_gold_upgrade_v2// CREATE PROCEDURE port_cube_gold_upgrade_v2() gold_upgrade: BEGIN DECLARE current_version INT DEFAULT 0; DECLARE present INT DEFAULT 0; SELECT version INTO current_version FROM port_cube_gold_version WHERE id=1; IF current_version NOT IN (1,2) THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='Expected gold addon version 1 or 2'; END IF; SELECT COUNT(*) INTO present FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND ENGINE='InnoDB' AND TABLE_NAME IN ('port_cube_gold_version','port_cube_gold_intents'); IF present<>2 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='Gold addon foundation missing/nontransactional; retain all history'; END IF; CREATE TABLE IF NOT EXISTS port_cube_gold_sources ( request CHAR(32) CHARACTER SET ascii COLLATE ascii_bin PRIMARY KEY, account INT UNSIGNED NOT NULL, pid INT UNSIGNED NOT NULL, epoch BIGINT UNSIGNED NOT NULL, owner CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, session BIGINT UNSIGNED NOT NULL, cookie INT UNSIGNED NOT NULL, handle INT UNSIGNED NOT NULL, manifest VARBINARY(32772) NOT NULL, INDEX player_source(pid) ) ENGINE=InnoDB; SELECT COUNT(*) INTO present FROM information_schema.tables WHERE TABLE_SCHEMA=DATABASE() AND ENGINE='InnoDB' AND TABLE_NAME='port_cube_gold_sources'; IF present<>1 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='Gold source table is nontransactional'; END IF; SELECT COUNT(*) INTO present FROM information_schema.columns WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='port_cube_gold_sources' AND COLUMN_NAME IN ('request','account','pid','epoch','owner','session','cookie','handle','manifest'); IF present<>9 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='Gold source table incomplete; repair without dropping intents'; END IF; UPDATE port_cube_gold_version SET version=2 WHERE id=1 AND version=1; END// CALL port_cube_gold_upgrade_v2()// DROP PROCEDURE port_cube_gold_upgrade_v2// DELIMITER ;