Core/DB: Fix installing Full DB from TC

This commit is contained in:
hondacrx
2018-03-02 18:15:07 -05:00
parent abbdd261b4
commit 3d3dd235a7
2 changed files with 15 additions and 15 deletions
+12 -12
View File
@@ -30,18 +30,18 @@ namespace Framework.Database
_updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask); _updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask);
} }
public void AddDatabase<T>(MySqlBase<T> database, string dbName) public void AddDatabase<T>(MySqlBase<T> database, string baseDBName)
{ {
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags); bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
_open.Add(() => _open.Add(() =>
{ {
MySqlConnectionInfo connectionObject = new MySqlConnectionInfo MySqlConnectionInfo connectionObject = new MySqlConnectionInfo
{ {
Host = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Host", ""), Host = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Host", ""),
Port = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Port", ""), Port = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Port", ""),
Username = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Username", ""), Username = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Username", ""),
Password = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Password", ""), Password = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Password", ""),
Database = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Database", "") Database = ConfigMgr.GetDefaultValue(baseDBName + "DatabaseInfo.Database", "")
}; };
var error = database.Initialize(connectionObject); var error = database.Initialize(connectionObject);
@@ -50,14 +50,14 @@ namespace Framework.Database
// Database does not exist // Database does not exist
if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup) if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup)
{ {
Log.outInfo(LogFilter.ServerLoading, $"Database \"{dbName}\" does not exist, do you want to create it? [yes (default) / no]: "); Log.outInfo(LogFilter.ServerLoading, $"Database \"{connectionObject.Database}\" does not exist, do you want to create it? [yes (default) / no]: ");
string answer = Console.ReadLine(); string answer = Console.ReadLine();
if (string.IsNullOrEmpty(answer) || answer[0] != 'y') if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
return false; return false;
Log.outInfo(LogFilter.ServerLoading, $"Creating database \"{dbName}\"..."); Log.outInfo(LogFilter.ServerLoading, $"Creating database \"{connectionObject.Database}\"...");
string sqlString = $"CREATE DATABASE `{dbName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"; string sqlString = $"CREATE DATABASE `{connectionObject.Database}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
// 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 (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None) if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
error = MySqlErrorCode.None; error = MySqlErrorCode.None;
@@ -66,7 +66,7 @@ namespace Framework.Database
// If the error wasn't handled quit // If the error wasn't handled quit
if (error != MySqlErrorCode.None) if (error != MySqlErrorCode.None)
{ {
Log.outError(LogFilter.ServerLoading, $"\nDatabase {dbName} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors."); Log.outError(LogFilter.ServerLoading, $"\nDatabase {connectionObject.Database} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.");
return false; return false;
} }
@@ -84,7 +84,7 @@ namespace Framework.Database
database.Apply("SET GLOBAL max_allowed_packet=1073741824;"); database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
if (!database.GetUpdater().Populate()) if (!database.GetUpdater().Populate())
{ {
Log.outError(LogFilter.ServerLoading, $"Could not populate the {dbName} database, see log for details."); Log.outError(LogFilter.ServerLoading, $"Could not populate the {database.GetDatabaseName()} database, see log for details.");
return false; return false;
} }
return true; return true;
@@ -96,7 +96,7 @@ namespace Framework.Database
database.Apply("SET GLOBAL max_allowed_packet=1073741824;"); database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
if (!database.GetUpdater().Update()) if (!database.GetUpdater().Update())
{ {
Log.outError(LogFilter.ServerLoading, $"Could not update the {dbName} database, see log for details."); Log.outError(LogFilter.ServerLoading, $"Could not update the {database.GetDatabaseName()} database, see log for details.");
return false; return false;
} }
return true; return true;
+3 -3
View File
@@ -51,17 +51,17 @@ namespace Framework.Database
fileName = @"\sql\base\characters_database.sql"; fileName = @"\sql\base\characters_database.sql";
break; break;
case "WorldDatabase": case "WorldDatabase":
fileName = @"\TDB_world_720.00_2017_04_18.sql"; fileName = @"\sql\TDB_world_735.00_2018_02_19.sql";
break; break;
case "HotfixDatabase": case "HotfixDatabase":
fileName = @"\TDB_hotfixes_720.00_2017_04_18.sql"; fileName = @"\sql\TDB_hotfixes_735.00_2018_02_19.sql";
break; break;
} }
if (!File.Exists(path + fileName)) if (!File.Exists(path + fileName))
{ {
Log.outError(LogFilter.SqlUpdates, $"File \"{fileName}\" is missing, download it from \"http://www.trinitycore.org/f/files/category/1-database/\"" + Log.outError(LogFilter.SqlUpdates, $"File \"{fileName}\" is missing, download it from \"http://www.trinitycore.org/f/files/category/1-database/\"" +
" and place it in your worldserver directory."); " and place it in your sql directory.");
return false; return false;
} }