2014-10-02 16:05:44 -04:00
|
|
|
'use strict';
|
2014-05-23 08:23:50 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
/**
|
|
|
|
* Update handler for transition database version 2 -> 3
|
|
|
|
*
|
|
|
|
* In database version 3, we introduced new flags to the messages, also
|
|
|
|
* the outbox uses artificial uids
|
|
|
|
*/
|
2014-12-11 07:57:40 -05:00
|
|
|
function update(options) {
|
2014-10-02 16:05:44 -04:00
|
|
|
var emailDbType = 'email_',
|
|
|
|
versionDbType = 'dbVersion',
|
|
|
|
postUpdateDbVersion = 3;
|
2014-05-23 08:23:50 -04:00
|
|
|
|
2014-10-02 16:05:44 -04:00
|
|
|
// remove the emails
|
2014-12-11 07:57:40 -05:00
|
|
|
return options.userStorage.removeList(emailDbType).then(function() {
|
2014-10-02 16:05:44 -04:00
|
|
|
// update the database version to postUpdateDbVersion
|
2014-12-11 07:57:40 -05:00
|
|
|
return options.appConfigStorage.storeList([postUpdateDbVersion], versionDbType);
|
2014-10-02 16:05:44 -04:00
|
|
|
});
|
|
|
|
}
|
2014-05-23 08:23:50 -04:00
|
|
|
|
2014-10-08 06:34:34 -04:00
|
|
|
module.exports = update;
|