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.
session-ios/SessionSnodeKit/Database/Migrations/_006_DropSnodeCache.swift

30 lines
1.4 KiB
Swift

// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
/// This migration drops the current `SnodePool` and `SnodeSet` and their associated jobs as they are handled by `libSession` now
enum _006_DropSnodeCache: Migration {
static let target: TargetMigrations.Identifier = .snodeKit
static let identifier: String = "DropSnodeCache" // stringlint:disable
static let needsConfigSync: Bool = false
static let minExpectedRunDuration: TimeInterval = 0.1
static let fetchedTables: [(TableRecord & FetchableRecord).Type] = []
static let createdOrAlteredTables: [(TableRecord & FetchableRecord).Type] = []
static let droppedTables: [(TableRecord & FetchableRecord).Type] = [
_001_InitialSetupMigration.LegacySnode.self, _001_InitialSetupMigration.LegacySnodeSet.self
]
static func migrate(_ db: Database, using dependencies: Dependencies) throws {
try db.drop(table: _001_InitialSetupMigration.LegacySnode.self)
try db.drop(table: _001_InitialSetupMigration.LegacySnodeSet.self)
// Drop the old snode cache jobs as well
let variants: [Job.Variant] = [._legacy_getSnodePool, ._legacy_buildPaths, ._legacy_getSwarm]
try Job.filter(variants.contains(Job.Columns.variant)).deleteAll(db)
Storage.update(progress: 1, for: self, in: target)
}
}