mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
Swift
34 lines
1.2 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
@objc(SNSOGSV4Migration)
|
|
public class SOGSV4Migration: OWSDatabaseMigration {
|
|
|
|
@objc
|
|
class func migrationId() -> String {
|
|
return "005"
|
|
}
|
|
|
|
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) {
|
|
self.doMigrationAsync(completion: completion)
|
|
}
|
|
|
|
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) {
|
|
// These collections became redundant in SOGS V4
|
|
let lastMessageServerIDCollection: String = "SNLastMessageServerIDCollection"
|
|
let lastDeletionServerIDCollection: String = "SNLastDeletionServerIDCollection"
|
|
let authTokenCollection: String = "SNAuthTokenCollection"
|
|
|
|
Storage.write(with: { transaction in
|
|
transaction.removeAllObjects(inCollection: lastMessageServerIDCollection)
|
|
transaction.removeAllObjects(inCollection: lastDeletionServerIDCollection)
|
|
transaction.removeAllObjects(inCollection: authTokenCollection)
|
|
|
|
self.save(with: transaction) // Intentionally capture self
|
|
}, completion: {
|
|
completion()
|
|
})
|
|
}
|
|
}
|