From bf632bfa5485a1a0651b33d1287ab4f34813659d Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 3 Feb 2016 15:16:38 -0800 Subject: [PATCH] Fix migrations Migrations should always call next() exactly once. // FREEBIE --- js/database.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/database.js b/js/database.js index 69a7ee32..b1441a72 100644 --- a/js/database.js +++ b/js/database.js @@ -38,6 +38,7 @@ { version: "2.0", migrate: function(transaction, next) { + console.log('migration 2.0'); var conversations = transaction.objectStore("conversations"); conversations.createIndex("search", "tokens", { unique: false, multiEntry: true }); @@ -48,11 +49,13 @@ model.save(); }); }); + next(); } }, { version: "3.0", migrate: function(transaction, next) { + console.log('migration 3.0'); var conversations = transaction.objectStore("items"); var all = new Whisper.ConversationCollection(); @@ -67,11 +70,13 @@ storage.remove('unreadCount'); storage.put('unreadCount', unreadCount); }); + next(); } }, { version: "4.0", migrate: function(transaction, next) { + console.log('migration 4.0'); var all = new Whisper.ConversationCollection(); all.fetch().then(function() { all.each(function(c) { @@ -79,19 +84,23 @@ c.save(); }); }); + next(); } }, { version: "5.0", migrate: function(transaction, next) { + console.log('migration 5.0'); if (storage.get("chromiumRegistrationDone") === "") { storage.put("chromiumRegistrationDoneEver", ""); } + next(); } }, { version: "6.0", migrate: function(transaction, next) { + console.log('migration 6.0'); storage.onready(function() { if (storage.get("chromiumRegistrationDone") === "") { storage.put("chromiumRegistrationDoneEver", ""); @@ -99,12 +108,15 @@ } }); storage.fetch(); + next(); } }, { version: "7.0", migrate: function(transaction, next) { + console.log('migration 7.0'); transaction.db.createObjectStore("debug"); + next(); } } ];