@ -14,6 +14,7 @@
version : "1.0" ,
migrate : function ( transaction , next ) {
console . log ( 'migration 1.0' ) ;
console . log ( 'creating object stores' ) ;
var messages = transaction . db . createObjectStore ( "messages" ) ;
messages . createIndex ( "conversation" , [ "conversationId" , "received_at" ] , { unique : false } ) ;
messages . createIndex ( "receipt" , "sent_at" , { unique : false } ) ;
@ -42,6 +43,8 @@
var conversations = transaction . objectStore ( "conversations" ) ;
conversations . createIndex ( "search" , "tokens" , { unique : false , multiEntry : true } ) ;
window . addEventListener ( 'storage_ready' , function ( ) {
console . log ( 'migrating search tokens' ) ;
var all = new Whisper . ConversationCollection ( ) ;
all . fetch ( ) . then ( function ( ) {
all . each ( function ( model ) {
@ -49,6 +52,7 @@
model . save ( ) ;
} ) ;
} ) ;
} ) ;
next ( ) ;
}
} ,
@ -58,6 +62,8 @@
console . log ( 'migration 3.0' ) ;
var conversations = transaction . objectStore ( "items" ) ;
window . addEventListener ( 'storage_ready' , function ( ) {
console . log ( 'migrating unread count' ) ;
var all = new Whisper . ConversationCollection ( ) ;
all . fetch ( ) . then ( function ( ) {
var unreadCount = all . reduce ( function ( total , model ) {
@ -70,6 +76,7 @@
storage . remove ( 'unreadCount' ) ;
storage . put ( 'unreadCount' , unreadCount ) ;
} ) ;
} ) ;
next ( ) ;
}
} ,
@ -77,6 +84,8 @@
version : "4.0" ,
migrate : function ( transaction , next ) {
console . log ( 'migration 4.0' ) ;
window . addEventListener ( 'storage_ready' , function ( ) {
console . log ( 'migrating search tokens' ) ;
var all = new Whisper . ConversationCollection ( ) ;
all . fetch ( ) . then ( function ( ) {
all . each ( function ( c ) {
@ -84,6 +93,7 @@
c . save ( ) ;
} ) ;
} ) ;
} ) ;
next ( ) ;
}
} ,
@ -91,9 +101,12 @@
version : "5.0" ,
migrate : function ( transaction , next ) {
console . log ( 'migration 5.0' ) ;
window . addEventListener ( 'storage_ready' , function ( ) {
console . log ( 'migrating registration flags' ) ;
if ( storage . get ( "chromiumRegistrationDone" ) === "" ) {
storage . put ( "chromiumRegistrationDoneEver" , "" ) ;
}
} ) ;
next ( ) ;
}
} ,
@ -101,12 +114,15 @@
version : "6.0" ,
migrate : function ( transaction , next ) {
console . log ( 'migration 6.0' ) ;
window . addEventListener ( 'storage_ready' , function ( ) {
console . log ( 'migrating registration flags' ) ;
storage . onready ( function ( ) {
if ( storage . get ( "chromiumRegistrationDone" ) === "" ) {
storage . put ( "chromiumRegistrationDoneEver" , "" ) ;
next ( ) ;
}
} ) ;
} ) ;
next ( ) ;
}
} ,
@ -114,6 +130,7 @@
version : "7.0" ,
migrate : function ( transaction , next ) {
console . log ( 'migration 7.0' ) ;
console . log ( 'creating debug log' ) ;
transaction . db . createObjectStore ( "debug" ) ;
next ( ) ;
}