From 42870028e473a3e46ec30a77ca9c79547fea6e1b Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:19:13 -0700 Subject: [PATCH] Remove complex migration Only shooting gallery had a value put in the wrong column. All others were either already correct or unimplemented. --- dDatabase/MigrationRunner.cpp | 23 +------------------ dDatabase/MigrationRunner.h | 1 - dGame/LeaderboardManager.h | 4 ++-- dMasterServer/MasterServer.cpp | 3 --- .../dlu/10_Update_Leaderboard_Columns.sql | 1 - .../dlu/9_Update_Leaderboard_Storage.sql | 14 ++++++----- 6 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 migrations/dlu/10_Update_Leaderboard_Columns.sql diff --git a/dDatabase/MigrationRunner.cpp b/dDatabase/MigrationRunner.cpp index d9c5aa38..40259a74 100644 --- a/dDatabase/MigrationRunner.cpp +++ b/dDatabase/MigrationRunner.cpp @@ -9,6 +9,7 @@ #include "BinaryPathFinder.h" #include "CDActivitiesTable.h" #include "CDClientManager.h" +#include "LeaderboardManager.h" #include @@ -58,8 +59,6 @@ void MigrationRunner::RunMigrations() { Game::logger->Log("MigrationRunner", "Running migration: %s", migration.name.c_str()); if (migration.name == "dlu/5_brick_model_sd0.sql") { runSd0Migrations = true; - } else if (migration.name == "dlu/10_Update_Leaderboard_Columns.sql") { - continue; } else { finalSQL.append(migration.data.c_str()); } @@ -160,23 +159,3 @@ void MigrationRunner::RunSQLiteMigrations() { Game::logger->Log("MigrationRunner", "CDServer database is up to date."); } - -void MigrationRunner::MigrateLeaderboard() { - Game::logger->Log("MigrationRunner", "Checking if leaderboard migration needs to be run..."); - { - std::unique_ptr stmt(Database::CreatePreppedStmt("SELECT * FROM migration_history WHERE name = ?;")); - stmt->setString(1, "dlu/10_Update_Leaderboard_Columns.sql"); - std::unique_ptr res(stmt->executeQuery()); - if (res->next()) { - Game::logger->Log("MigrationRunner", "Leaderboard migration has already been run."); - return; - } - } - auto activitiesTable = CDClientManager::Instance().GetTable(); - auto leaderboards = activitiesTable->Query([=](const CDActivities& entry) { - return entry.leaderboardType != -1; - }); - for (auto entry : leaderboards) { - Game::logger->Log("MigrationRunner", "Got leaderboard type %i for activity %i", entry.leaderboardType, entry.ActivityID); - } -} diff --git a/dDatabase/MigrationRunner.h b/dDatabase/MigrationRunner.h index 00a1d720..0cb36d53 100644 --- a/dDatabase/MigrationRunner.h +++ b/dDatabase/MigrationRunner.h @@ -10,5 +10,4 @@ struct Migration { namespace MigrationRunner { void RunMigrations(); void RunSQLiteMigrations(); - void MigrateLeaderboard(); }; diff --git a/dGame/LeaderboardManager.h b/dGame/LeaderboardManager.h index 4a42a268..ad05a1ca 100644 --- a/dGame/LeaderboardManager.h +++ b/dGame/LeaderboardManager.h @@ -37,8 +37,8 @@ public: Racing, MonumentRace, FootRace, - UnusedLeaderboard4,// There is no 4 defined anywhere in the client or cdclient - Survival = 5, + UnusedLeaderboard4, // There is no 4 defined anywhere in the cdclient, but it takes a Score. + Survival, SurvivalNS, Donations, None = UINT_MAX diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 61dbb121..cc2bdd90 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -202,9 +202,6 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - // This migration relies on cdclient data so run it last - MigrationRunner::MigrateLeaderboard(); - //If the first command line argument is -a or --account then make the user //input a username and password, with the password being hidden. if (argc > 1 && diff --git a/migrations/dlu/10_Update_Leaderboard_Columns.sql b/migrations/dlu/10_Update_Leaderboard_Columns.sql deleted file mode 100644 index c9afb81e..00000000 --- a/migrations/dlu/10_Update_Leaderboard_Columns.sql +++ /dev/null @@ -1 +0,0 @@ -# This migration is a mock. See the real migration in MigrationRunner::MigrateLeaderboard. diff --git a/migrations/dlu/9_Update_Leaderboard_Storage.sql b/migrations/dlu/9_Update_Leaderboard_Storage.sql index 1b3b1f13..5e9c5fa2 100644 --- a/migrations/dlu/9_Update_Leaderboard_Storage.sql +++ b/migrations/dlu/9_Update_Leaderboard_Storage.sql @@ -1,8 +1,10 @@ -ALTER TABLE leaderboard -ADD COLUMN hitPercentage FLOAT NOT NULL DEFAULT 0, -ADD COLUMN streak INT NOT NULL DEFAULT 0, -ADD COLUMN bestLapTime FLOAT NOT NULL DEFAULT 0, -ADD COLUMN numWins INT NOT NULL DEFAULT 0, -MODIFY time FLOAT NOT NULL DEFAULT 0; +ALTER TABLE leaderboard + ADD COLUMN hitPercentage FLOAT NOT NULL DEFAULT 0, + ADD COLUMN streak INT NOT NULL DEFAULT 0, + ADD COLUMN bestLapTime FLOAT NOT NULL DEFAULT 0, + ADD COLUMN numWins INT NOT NULL DEFAULT 0, + MODIFY time FLOAT NOT NULL DEFAULT 0; ALTER TABLE leaderboard CHANGE time bestTime float; + +UPDATE leaderboard SET streak = bestTime where game_id = 1864;