mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Database] Implement native database migrations in server (#2857)
* [Database] Implement native database updates in server * Cleanup * Delete db_update_manifest.txt * Bots updates * Final tweaks * Revert manifest * Tweaks * Remove code from eqemu_server.pl * Update database_update.cpp * Add user prompt update skipping with timeouts * Add termcolor IS_TTY is check * Update database_conversions.cpp * Remove large migrations * Push * fix headers. * Remove last of non-bot large migrations * Update database_update_manifest.cpp * More purging * Tweaks * Bot migrations * More work * Tweaks * Implement multi-statement query execution only for migrations * Add CLI database:updates * Add bootstrap commands * Upload bootstrap sql's * Update bot_tables_bootstrap.sql * Update bot_tables_bootstrap.sql * Add mercs:bootstrap and bots:bootstrap * Update bot_tables_bootstrap.sql * Update database.cpp * Update bot_tables_bootstrap.sql * More cleanup * Add mercs:disable and bots:disable * Update eqemu_server.pl * Update eqemu_server.pl * Update eqemu_server.pl * Test cases * Update eqemu_server.pl * Delete 2023_05_08_character_tribute_primary_key.sql * Post rebase fixes * Post rebase tweaks * Delete errant files * Rebase files from master * More adjustments * Delete files no longer used * Add missing migrations * bots:bootstrap is now bots:enable --------- Co-authored-by: Aeadoin <109764533+Aeadoin@users.noreply.github.com>
This commit is contained in:
+31
-18
@@ -83,6 +83,8 @@ extern volatile bool is_zone_loaded;
|
||||
#include "zone_event_scheduler.h"
|
||||
#include "../common/file.h"
|
||||
#include "../common/events/player_event_logs.h"
|
||||
#include "../common/path_manager.h"
|
||||
#include "../common/database/database_update.h"
|
||||
|
||||
EntityList entity_list;
|
||||
WorldServer worldserver;
|
||||
@@ -102,6 +104,7 @@ ZoneEventScheduler event_scheduler;
|
||||
WorldContentService content_service;
|
||||
PathManager path;
|
||||
PlayerEventLogs player_event_logs;
|
||||
DatabaseUpdate database_update;
|
||||
|
||||
const SPDat_Spell_Struct* spells;
|
||||
int32 SPDAT_RECORDS = -1;
|
||||
@@ -259,6 +262,24 @@ int main(int argc, char** argv) {
|
||||
content_db.SetMutex(mutex);
|
||||
}
|
||||
|
||||
//rules:
|
||||
{
|
||||
std::string tmp;
|
||||
if (database.GetVariable("RuleSet", tmp)) {
|
||||
LogInfo("Loading rule set [{}]", tmp.c_str());
|
||||
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str(), false)) {
|
||||
LogError("Failed to load ruleset [{}], falling back to defaults", tmp.c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!RuleManager::Instance()->LoadRules(&database, "default", false)) {
|
||||
LogInfo("No rule set configured, using default rules");
|
||||
}
|
||||
}
|
||||
|
||||
EQ::InitializeDynamicLookups();
|
||||
}
|
||||
|
||||
/* Register Log System and Settings */
|
||||
LogSys.SetDatabase(&database)
|
||||
->SetLogPath(path.GetLogPath())
|
||||
@@ -268,6 +289,16 @@ int main(int argc, char** argv) {
|
||||
|
||||
player_event_logs.SetDatabase(&database)->Init();
|
||||
|
||||
const auto c = EQEmuConfig::get();
|
||||
if (c->auto_database_updates) {
|
||||
if (database_update.SetDatabase(&database)->HasPendingUpdates()) {
|
||||
LogWarning("Database is not up to date [world] needs to be ran to apply updates, shutting down in 5 seconds");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
LogInfo("Exiting due to pending database updates");
|
||||
std::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Guilds */
|
||||
guild_mgr.SetDatabase(&database);
|
||||
GuildBanks = nullptr;
|
||||
@@ -368,24 +399,6 @@ int main(int argc, char** argv) {
|
||||
LogInfo("Loaded [{}] commands loaded", Strings::Commify(std::to_string(retval)));
|
||||
}
|
||||
|
||||
//rules:
|
||||
{
|
||||
std::string tmp;
|
||||
if (database.GetVariable("RuleSet", tmp)) {
|
||||
LogInfo("Loading rule set [{}]", tmp.c_str());
|
||||
if (!RuleManager::Instance()->LoadRules(&database, tmp, false)) {
|
||||
LogError("Failed to load ruleset [{}], falling back to defaults", tmp.c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!RuleManager::Instance()->LoadRules(&database, "default", false)) {
|
||||
LogInfo("No rule set configured, using default rules");
|
||||
}
|
||||
}
|
||||
|
||||
EQ::InitializeDynamicLookups();
|
||||
}
|
||||
|
||||
content_service.SetDatabase(&database)
|
||||
->SetExpansionContext()
|
||||
->ReloadContentFlags();
|
||||
|
||||
Reference in New Issue
Block a user