fix(Core/DBUpdater): Fix sql files not being applied in alphabetic order (#24206)
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
std::string DBUpdaterUtil::GetCorrectedMySQLExecutable()
|
std::string DBUpdaterUtil::GetCorrectedMySQLExecutable()
|
||||||
{
|
{
|
||||||
@@ -396,16 +397,23 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::filesystem::directory_iterator itr(DirPath); itr != DirItr; ++itr)
|
std::vector<std::filesystem::path> sqlFiles;
|
||||||
{
|
|
||||||
if (itr->path().extension() != ".sql")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
LOG_INFO("sql.updates", ">> Applying \'{}\'...", itr->path().filename().generic_string());
|
for (const auto &entry : std::filesystem::directory_iterator(DirPath))
|
||||||
|
{
|
||||||
|
if (entry.path().extension() == ".sql")
|
||||||
|
sqlFiles.push_back(entry.path());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(sqlFiles.begin(), sqlFiles.end());
|
||||||
|
|
||||||
|
for (const auto &file : sqlFiles)
|
||||||
|
{
|
||||||
|
LOG_INFO("sql.updates", ">> Applying \'{}\'...", file.filename().generic_string());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ApplyFile(pool, itr->path());
|
ApplyFile(pool, file);
|
||||||
}
|
}
|
||||||
catch (UpdateException&)
|
catch (UpdateException&)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user