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/SessionUtilitiesKit/Database/Types/Migration.swift

24 lines
776 B
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
public protocol Migration {
static var target: TargetMigrations.Identifier { get }
static var identifier: String { get }
static var needsConfigSync: Bool { get }
static var minExpectedRunDuration: TimeInterval { get }
static func migrate(_ db: Database) throws
}
public extension Migration {
static func loggedMigrate(_ targetIdentifier: TargetMigrations.Identifier) -> ((_ db: Database) throws -> ()) {
return { (db: Database) in
SNLog("[Migration Info] Starting \(targetIdentifier.key(with: self))")
try migrate(db)
SNLog("[Migration Info] Completed \(targetIdentifier.key(with: self))")
}
}
}