From 7f549a3f34aa049213932e908adaccb2eda2ce45 Mon Sep 17 00:00:00 2001 From: Peter Eliasson Date: Thu, 21 Jul 2016 21:21:09 +0200 Subject: [PATCH] Migration from old -> new zone ids. --- src/main.lua | 2 +- src/migrate.lua | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main.lua b/src/main.lua index fdcd630..26790e3 100644 --- a/src/main.lua +++ b/src/main.lua @@ -40,7 +40,7 @@ addon.dbDefaults = { -- The current db version. Migrate the database if -- version of database doesn't match this version. -addon.dbVersion = 10; +addon.dbVersion = 11; -- Constants DEBUG_PRINT = false; diff --git a/src/migrate.lua b/src/migrate.lua index e47893d..c5b371b 100644 --- a/src/migrate.lua +++ b/src/migrate.lua @@ -85,10 +85,50 @@ local function migrate9to10(db) return 10; end +local function migrate10to11(db) + local highscoreDb = db.realm.modules["highscore"]; + + -- Switched to using GetInstanceInfo for zone ids + + local translateIds = { + [994] = 1228, -- Highmaul + [988] = 1205, -- Blackrock Foundry + [1026] = 1448, -- Hellfire Citadel + } + + for zoneId, zoneData in pairs(highscoreDb.zones) do + newId = translateIds[zoneId]; + if newId then + highscoreDb.zones[newId] = zoneData + highscoreDb.zones[zoneId] = nil + end + end + + for _, guildData in pairs(highscoreDb.guilds) do + for zoneId, zoneData in pairs(guildData.zones) do + newId = translateIds[zoneId]; + if newId then + guildData.zones[newId] = zoneData + guildData.zones[zoneId] = nil + end + end + end + + for _, groupData in pairs(highscoreDb.groupParses) do + if translateIds[groupData.zoneId] then + groupData.zoneId = translateIds[groupData.zoneId] + end + end + + + return 11 +end + local migrateTable = { [7] = migrate7to8, [8] = migrate8to9, - [9] = migrate9to10 + [9] = migrate9to10, + [10] = migrate10to11 } local function resetDb() -- 1.7.9.5