diff --git a/src/common/sql.cpp b/src/common/sql.cpp index 4792dedfa6..08d6032ecf 100644 --- a/src/common/sql.cpp +++ b/src/common/sql.cpp @@ -3,6 +3,7 @@ #include "sql.hpp" +#include #ifdef WIN32 #include "winapi.hpp" #endif @@ -1062,8 +1063,9 @@ void Sql_UpgradesChecker(Sql *sql_handle, e_sql_database schema) { sql_update_db.load(); std::vector new_updates, skipped_updates; + std::map> ordered_sql_update_db(sql_update_db.begin(), sql_update_db.end()); // Create an ordered list (by ID) to make sure updates are applied sequentially - for (const auto &updateIt : sql_update_db) { + for (const auto &updateIt : ordered_sql_update_db) { std::shared_ptr update = updateIt.second; if (!update->patchdate.empty()) // Already applied @@ -1162,6 +1164,7 @@ void Sql_UpgradesChecker(Sql *sql_handle, e_sql_database schema) { save.close(); } + ordered_sql_update_db.clear(); new_updates.clear(); skipped_updates.clear(); }