@@ -113,6 +113,7 @@ const LOKI_SCHEMA_VERSIONS = [
113
113
updateToSessionSchemaVersion42 ,
114
114
updateToSessionSchemaVersion43 ,
115
115
updateToSessionSchemaVersion44 ,
116
+ updateToSessionSchemaVersion45 ,
116
117
] ;
117
118
118
119
function updateToSessionSchemaVersion1 ( currentVersion : number , db : BetterSqlite3 . Database ) {
@@ -2100,6 +2101,39 @@ function updateToSessionSchemaVersion44(currentVersion: number, db: BetterSqlite
2100
2101
console . log ( `updateToSessionSchemaVersion${ targetVersion } : success!` ) ;
2101
2102
}
2102
2103
2104
+ function updateToSessionSchemaVersion45 ( currentVersion : number , db : BetterSqlite3 . Database ) {
2105
+ const targetVersion = 45 ;
2106
+ if ( currentVersion >= targetVersion ) {
2107
+ return ;
2108
+ }
2109
+
2110
+ console . log ( `updateToSessionSchemaVersion${ targetVersion } : starting...` ) ;
2111
+
2112
+ db . transaction ( ( ) => {
2113
+ try {
2114
+ const loggedInUser = getLoggedInUserConvoDuringMigration ( db ) ;
2115
+
2116
+ if ( ! loggedInUser || ! loggedInUser ?. ourKeys . publicKeyHex ) {
2117
+ throw new Error ( 'publicKeyHex was empty. Considering no users are logged in' ) ;
2118
+ }
2119
+
2120
+ const { publicKeyHex } = loggedInUser . ourKeys ;
2121
+ // if another of our device has pushed a multipart message and we have dropped it locally
2122
+ // as we didn't support multi part yet, we need to refetch the message from the swarm.
2123
+ // Note: this is only needed for our own contacts config.
2124
+ db . prepare (
2125
+ `DELETE FROM ${ LAST_HASHES_TABLE } WHERE id = '${ publicKeyHex } ' AND namespace = 3;` // UserContacts
2126
+ ) . run ( ) ;
2127
+ } catch ( e ) {
2128
+ // if no users are logged in, we can just continue here. Nothing is due to clean
2129
+ }
2130
+
2131
+ writeSessionSchemaVersion ( targetVersion , db ) ;
2132
+ } ) ( ) ;
2133
+
2134
+ console . log ( `updateToSessionSchemaVersion${ targetVersion } : success!` ) ;
2135
+ }
2136
+
2103
2137
export function printTableColumns ( table : string , db : BetterSqlite3 . Database ) {
2104
2138
console . info ( db . pragma ( `table_info('${ table } ');` ) ) ;
2105
2139
}
0 commit comments