diff options
Diffstat (limited to 'lib/wallet/db.ts')
-rw-r--r-- | lib/wallet/db.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/wallet/db.ts b/lib/wallet/db.ts index 2503468d5..9374aa447 100644 --- a/lib/wallet/db.ts +++ b/lib/wallet/db.ts @@ -25,7 +25,7 @@ */ const DB_NAME = "taler"; -const DB_VERSION = 1; +const DB_VERSION = 5; /** * Return a promise that resolves @@ -45,7 +45,8 @@ export function openTalerDb(): Promise<IDBDatabase> { console.log("DB: upgrade needed: oldVersion = " + e.oldVersion); switch (e.oldVersion) { case 0: // DB does not exist yet - const exchanges = db.createObjectStore("exchanges", {keyPath: "baseUrl"}); + const exchanges = db.createObjectStore("exchanges", + {keyPath: "baseUrl"}); exchanges.createIndex("pubKey", "masterPublicKey"); db.createObjectStore("reserves", {keyPath: "reserve_pub"}); db.createObjectStore("denoms", {keyPath: "denomPub"}); @@ -68,6 +69,15 @@ export function openTalerDb(): Promise<IDBDatabase> { }); history.createIndex("timestamp", "timestamp"); break; + default: + if (e.oldVersion != DB_VERSION) { + window.alert("Incompatible wallet dababase version, please reset" + + " db."); + chrome.browserAction.setBadgeText({text: "R!"}); + chrome.browserAction.setBadgeBackgroundColor({color: "#F00"}); + throw Error("incompatible DB"); + } + break; } }; }); |