- //document.getElementById("debug").textContent = "mainDB upgraded.";
- // Create a "prefs" objectStore.
- var prefsStore = mainDB.createObjectStore("prefs");
- // Create a "track" objectStore.
- var trackStore = mainDB.createObjectStore("track", {autoIncrement: true});
+ var ver = mainDB.version || 0; // version is empty string for a new DB
+ if (gDebug)
+ console.log("mainDB has version " + ver + ", upgrade needed.");
+ if (!mainDB.objectStoreNames.contains("prefs")) {
+ // Create a "prefs" objectStore.
+ var prefsStore = mainDB.createObjectStore("prefs");
+ }
+ if (!mainDB.objectStoreNames.contains("track")) {
+ // Create a "track" objectStore.
+ var trackStore = mainDB.createObjectStore("track", {autoIncrement: true});
+ }
+ if (!mainDB.objectStoreNames.contains("tilecache")) {
+ // Create a "tilecache" objectStore.
+ var tilecacheStore = mainDB.createObjectStore("tilecache");
+ }