mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
Adding migration command to build script (updated) (#653)
* Added checks for migration runner * Added migration command to build script
This commit is contained in:
parent
b55606d41e
commit
ec4ed8fa7e
3
build.sh
3
build.sh
@ -7,3 +7,6 @@ cmake ..
|
|||||||
|
|
||||||
# Run make to build the project. To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `make -j8`
|
# Run make to build the project. To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `make -j8`
|
||||||
make
|
make
|
||||||
|
|
||||||
|
# Run migrations
|
||||||
|
./MasterServer -m
|
||||||
|
@ -85,6 +85,28 @@ int main(int argc, char** argv) {
|
|||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
|
|
||||||
|
if (argc > 1 && (strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--migrations") == 0)) {
|
||||||
|
//Connect to the MySQL Database
|
||||||
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
|
std::string mysql_database = config.GetValue("mysql_database");
|
||||||
|
std::string mysql_username = config.GetValue("mysql_username");
|
||||||
|
std::string mysql_password = config.GetValue("mysql_password");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
||||||
|
} catch (sql::SQLException& ex) {
|
||||||
|
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
|
||||||
|
Game::logger->Log("MigrationRunner", "Migrations not run\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MigrationRunner::RunMigrations();
|
||||||
|
Game::logger->Log("MigrationRunner", "Finished running migrations\n");
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
//Check CDClient exists
|
//Check CDClient exists
|
||||||
const std::string cdclient_path = "./res/CDServer.sqlite";
|
const std::string cdclient_path = "./res/CDServer.sqlite";
|
||||||
std::ifstream cdclient_fd(cdclient_path);
|
std::ifstream cdclient_fd(cdclient_path);
|
||||||
@ -127,14 +149,9 @@ int main(int argc, char** argv) {
|
|||||||
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
|
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1 && (strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--migrations") == 0)) {
|
|
||||||
MigrationRunner::RunMigrations();
|
|
||||||
Game::logger->Log("MigrationRunner", "Finished running migrations\n");
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//If the first command line argument is -a or --account then make the user
|
//If the first command line argument is -a or --account then make the user
|
||||||
//input a username and password, with the password being hidden.
|
//input a username and password, with the password being hidden.
|
||||||
if (argc > 1 &&
|
if (argc > 1 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user