diff Core.lua @ 86:22b37c800bc4

Database and comm versioning
author John@Yosemite-PC
date Sun, 15 Apr 2012 14:42:14 -0400
parents f938ec08d5a6
children 5ade79caeece
line wrap: on
line diff
--- a/Core.lua	Sat Apr 14 10:12:06 2012 -0400
+++ b/Core.lua	Sun Apr 15 14:42:14 2012 -0400
@@ -6,7 +6,7 @@
 -- (*) all actions should reference the player list rather than player names
 -- (?) player entries should persist as long as any list or change references
 -- (*) lists store number slots rather than flat indexing
--- ( ) database and comm versioning
+-- (*) database and comm versioning
 -- (_) limited communication - everyone trusts the loot master
 -- (*) single user + admin gui (manual suicides)
 -- (*) single user + admin gui (master loot)
@@ -38,6 +38,9 @@
 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
 -- 5) pairs() does not have a guaranteed iteration order
 
+dbversion = 1
+commversion = 1
+
 function OnInitialize()
 
     debug = true
@@ -49,6 +52,9 @@
     --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk")
 
     admin = db.profile.admin
+    if not db.profile.dbversion or db.profile.dbversion < dbversion then
+        UpgradeDB()
+    end
 
     local HandlePassThrough = function(...) HandleCommand(...) end
     bsk:RegisterChatCommand("bsk", HandlePassThrough)
@@ -209,3 +215,13 @@
     }
 }
 
+function UpgradeDB()
+    local mydbver = db.profile.dbversion or 0
+
+    if mydbver == 0 then -- difference between 0 and 1 is whether this field is present
+        db.profile.dbversion = 1
+        mydbver = 1
+    end
+
+
+end