diff --git a/common/database/database_update_manifest.h b/common/database/database_update_manifest.h index 2671ad4ce..1cce442f0 100644 --- a/common/database/database_update_manifest.h +++ b/common/database/database_update_manifest.h @@ -7192,14 +7192,15 @@ ALTER TABLE `character_parcels_containers` }, ManifestEntry{ .version = 9329, - .description = "2025_06_27_add_suppressed_to_character_buffs.sql", + .description = "2026_03_08_add_suppressed_to_character_buffs.sql", .check = "SHOW COLUMNS FROM `character_buffs` LIKE 'suppressed'", .condition = "empty", .match = "", .sql = R"( ALTER TABLE `character_buffs` ADD COLUMN `suppressed` tinyint(1) unsigned NOT NULL DEFAULT 0 AFTER `instrument_mod`; -)" +)", + .content_schema_update = false }, // -- template; copy/paste this when you need to create a new entry // ManifestEntry{ diff --git a/zone/cli/tests/cli_zone_state.cpp b/zone/cli/tests/cli_zone_state.cpp index 1eb391a81..2a8591341 100644 --- a/zone/cli/tests/cli_zone_state.cpp +++ b/zone/cli/tests/cli_zone_state.cpp @@ -828,9 +828,9 @@ inline void TestHpManaEnd() inline void TestClientBuffPersistence() { - constexpr uint32 test_character_id = 99999991; - constexpr uint16 normal_spell_id = 6824; - constexpr uint16 suppressed_spell_id = 6824; + constexpr uint32 test_character_id = 99999991; + constexpr uint16 normal_spell_id = 6824; + constexpr uint16 suppressed_spell_id = 2550; auto schema_check = database.QueryDatabase("SHOW COLUMNS FROM `character_buffs` LIKE 'suppressed'"); RunTest( diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 61229916c..4dfbdec29 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2925,15 +2925,33 @@ void ZoneDatabase::SaveBuffs(Client *client) v.emplace_back(e); } - database.TransactionBegin(); + const auto begin_result = database.QueryDatabase("START TRANSACTION"); + if (!begin_result.Success()) { + LogError( + "Failed to begin buff save transaction for character [{}] [{}]: {}", + client->GetCleanName(), + client->CharacterID(), + begin_result.ErrorMessage() + ); + return; + } - CharacterBuffsRepository::DeleteWhere( - database, + const auto delete_result = database.QueryDatabase( fmt::format( - "`character_id` = {}", + "DELETE FROM `character_buffs` WHERE `character_id` = {}", client->CharacterID() ) ); + if (!delete_result.Success()) { + database.TransactionRollback(); + LogError( + "Failed to delete existing buffs for character [{}] [{}]: {}", + client->GetCleanName(), + client->CharacterID(), + delete_result.ErrorMessage() + ); + return; + } if (!v.empty()) { const auto saved_count = CharacterBuffsRepository::ReplaceMany(database, v);