feat(Core/DryRun): add support db autoupdate for DryRun (#9572)

This commit is contained in:
Kargatum
2022-04-22 02:12:12 +07:00
committed by GitHub
parent 1501445b0a
commit c0210ad7f0
2 changed files with 9 additions and 7 deletions
@@ -84,7 +84,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
} }
// Database does not exist // Database does not exist
if ((error == ER_BAD_DB_ERROR) && updatesEnabledForThis && _autoSetup && !sConfigMgr->isDryRun()) if ((error == ER_BAD_DB_ERROR) && updatesEnabledForThis && _autoSetup)
{ {
// Try to create the database and connect again if auto setup is enabled // Try to create the database and connect again if auto setup is enabled
if (DBUpdater<T>::Create(pool) && (!pool.Open())) if (DBUpdater<T>::Create(pool) && (!pool.Open()))
@@ -112,7 +112,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
}); });
// Populate and update only if updates are enabled for this pool // Populate and update only if updates are enabled for this pool
if (updatesEnabledForThis && !sConfigMgr->isDryRun()) if (updatesEnabledForThis)
{ {
_populate.push([this, name, &pool]() -> bool _populate.push([this, name, &pool]() -> bool
{ {
+7 -5
View File
@@ -173,10 +173,13 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
LOG_WARN("sql.updates", "Database \"{}\" does not exist, do you want to create it? [yes (default) / no]: ", LOG_WARN("sql.updates", "Database \"{}\" does not exist, do you want to create it? [yes (default) / no]: ",
pool.GetConnectionInfo()->database); pool.GetConnectionInfo()->database);
std::string answer; if (!sConfigMgr->isDryRun())
std::getline(std::cin, answer); {
if (!answer.empty() && !(answer.substr(0, 1) == "y")) std::string answer;
return false; std::getline(std::cin, answer);
if (!answer.empty() && !(answer.substr(0, 1) == "y"))
return false;
}
LOG_INFO("sql.updates", "Creating database \"{}\"...", pool.GetConnectionInfo()->database); LOG_INFO("sql.updates", "Creating database \"{}\"...", pool.GetConnectionInfo()->database);
@@ -192,7 +195,6 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
} }
file << "CREATE DATABASE `" << pool.GetConnectionInfo()->database << "` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci;\n\n"; file << "CREATE DATABASE `" << pool.GetConnectionInfo()->database << "` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci;\n\n";
file.close(); file.close();
try try