From 7c03db9ba0fcbf10da8fc37ff55b6d987aab8541 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 2 Mar 2016 00:47:00 +0100 Subject: db versioning --- lib/wallet/db.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/wallet/db.ts') 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 { 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 { }); 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; } }; }); -- cgit v1.2.3