mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 862749 - B2G MMS: UpgradeSchema should also set defualt type to sms when the type is undefined. r=vyang
This commit is contained in:
parent
0c98e74953
commit
0f47fcd1a8
@ -21,7 +21,7 @@ const RIL_GETTHREADSCURSOR_CID =
|
||||
|
||||
const DEBUG = false;
|
||||
const DB_NAME = "sms";
|
||||
const DB_VERSION = 9;
|
||||
const DB_VERSION = 10;
|
||||
const MESSAGE_STORE_NAME = "sms";
|
||||
const THREAD_STORE_NAME = "thread";
|
||||
const PARTICIPANT_STORE_NAME = "participant";
|
||||
@ -205,6 +205,10 @@ MobileMessageDatabaseService.prototype = {
|
||||
if (DEBUG) debug("Upgrade to version 9. Add transactionId index for incoming MMS.");
|
||||
self.upgradeSchema8(event.target.transaction);
|
||||
break;
|
||||
case 9:
|
||||
if (DEBUG) debug("Upgrade to version 10. Upgrade type if it's not existing.");
|
||||
self.upgradeSchema9(event.target.transaction);
|
||||
break;
|
||||
default:
|
||||
event.target.transaction.abort();
|
||||
callback("Old database version: " + event.oldVersion, null);
|
||||
@ -597,6 +601,25 @@ MobileMessageDatabaseService.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
upgradeSchema9: function upgradeSchema9(transaction) {
|
||||
let messageStore = transaction.objectStore(MESSAGE_STORE_NAME);
|
||||
|
||||
// Update type attributes.
|
||||
messageStore.openCursor().onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
let messageRecord = cursor.value;
|
||||
if (messageRecord.type == undefined) {
|
||||
messageRecord.type = "sms";
|
||||
cursor.update(messageRecord);
|
||||
}
|
||||
cursor.continue();
|
||||
};
|
||||
},
|
||||
|
||||
createDomMessageFromRecord: function createDomMessageFromRecord(aMessageRecord) {
|
||||
if (DEBUG) {
|
||||
debug("createDomMessageFromRecord: " + JSON.stringify(aMessageRecord));
|
||||
|
Loading…
Reference in New Issue
Block a user