Update database.cpp

This commit is contained in:
Mitch Freeman 2025-04-26 17:21:36 -03:00
parent 3c4cc74a54
commit 2174f41505

View File

@ -2299,11 +2299,26 @@ void Database::ConvertInventoryToNewUniqueId()
}
TransactionBegin();
uint32 index = 0;
uint32 batch_size = 1000;
std::vector<InventoryRepository::Inventory> queue{};
queue.reserve(batch_size);
for (auto &r: results) {
r.item_unique_id = EQ::UniqueHashGenerator::generate();
queue.push_back(r);
index++;
if (index >= batch_size) {
InventoryRepository::ReplaceMany(*this, queue);
index = 0;
queue.clear();
}
}
if (!queue.empty()) {
InventoryRepository::ReplaceMany(*this, queue);
}
InventoryRepository::ReplaceMany(*this, results);
TransactionCommit();
LogInfo("Converted {} records", results.size());
}