[Character] Fix character copier due to schema change (#3805)

* [Character] Fix character copier due to schema change

* Tweak
This commit is contained in:
Chris Miles
2023-12-27 20:04:46 -06:00
committed by GitHub
parent 51cd43b4ea
commit 52763b6dd2
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -2246,6 +2246,11 @@ bool Database::CopyCharacter(
row = results.begin();
std::string new_character_id = row[0];
std::vector<std::string> 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;
}
}
}
+1 -1
View File
@@ -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"},