diff --git a/common/database.cpp b/common/database.cpp index a31ea62d19..7520c1eddb 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -2246,6 +2246,11 @@ bool Database::CopyCharacter( row = results.begin(); std::string new_character_id = row[0]; + std::vector tables_to_zero_id = { + "keyring", + "data_buckets", + }; + TransactionBegin(); for (const auto &iter : DatabaseSchema::GetCharacterTables()) { std::string table_name = iter.first; @@ -2279,6 +2284,10 @@ bool Database::CopyCharacter( std::string column = columns[column_index]; std::string value = row[column_index] ? row[column_index] : "null"; + if (column == "id" && Strings::Contains(tables_to_zero_id, table_name)) { + value = "0"; + } + if (column == character_id_column_name) { value = new_character_id; } @@ -2326,7 +2335,6 @@ bool Database::CopyCharacter( if (!insert.ErrorMessage().empty()) { TransactionRollback(); return false; - break; } } } diff --git a/common/database_schema.h b/common/database_schema.h index 8612356c5a..fdd158505f 100644 --- a/common/database_schema.h +++ b/common/database_schema.h @@ -71,7 +71,7 @@ namespace DatabaseSchema { {"character_tasks", "charid"}, {"character_tribute", "character_id"}, {"completed_tasks", "charid"}, - {"data_buckets", "id"}, + {"data_buckets", "character_id"}, {"faction_values", "char_id"}, {"friends", "charid"}, {"guild_members", "char_id"},