DarkflameServer/migrations/dlu/9_Update_Leaderboard_Storage.sql
2024-11-15 01:05:05 -08:00

19 lines
904 B
SQL

ALTER TABLE leaderboard
ADD COLUMN tertiaryScore DOUBLE NOT NULL DEFAULT 0,
ADD COLUMN numWins INTEGER NOT NULL DEFAULT 0,
ADD COLUMN timesPlayed INTEGER NOT NULL DEFAULT 1,
MODIFY time INTEGER NOT NULL DEFAULT 0;
/* Can only ALTER one column at a time... */
ALTER TABLE leaderboard CHANGE score primaryScore DOUBLE NOT NULL DEFAULT 0;
ALTER TABLE leaderboard CHANGE time secondaryScore DOUBLE NOT NULL DEFAULT 0 AFTER primaryScore;
/* A bit messy, but better than going through a bunch of code fixes all to be run once. */
UPDATE leaderboard SET
primaryScore = secondaryScore,
secondaryScore = 0 WHERE game_id IN (1, 44, 46, 47, 48, 49, 53, 103, 104, 108, 1901) AND secondaryScore > 0;
/* Do this last so we dont update entry times erroneously */
ALTER TABLE leaderboard
CHANGE last_played last_played DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP();