Update Migrations, Models
Summary: - Sources: Migrations, Models Stats: - 3 files changed, 10 insertions(+), 6 deletions(-)
This commit is contained in:
parent
0afaf34c78
commit
7520d195a2
@ -3,12 +3,12 @@ import Foundation
|
|||||||
public struct DefaultAggregatingMigration<Value: Codable & Sendable>: AggregatingMigration {
|
public struct DefaultAggregatingMigration<Value: Codable & Sendable>: AggregatingMigration {
|
||||||
public let destinationKey: StorageKey<Value>
|
public let destinationKey: StorageKey<Value>
|
||||||
public let sourceKeys: [AnyStorageKey]
|
public let sourceKeys: [AnyStorageKey]
|
||||||
public let aggregateAction: ([AnyCodable]) async throws -> Value
|
public let aggregateAction: @Sendable ([AnyCodable]) async throws -> Value
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
destinationKey: StorageKey<Value>,
|
destinationKey: StorageKey<Value>,
|
||||||
sourceKeys: [AnyStorageKey],
|
sourceKeys: [AnyStorageKey],
|
||||||
aggregate: @escaping ([AnyCodable]) async throws -> Value
|
aggregate: @escaping @Sendable ([AnyCodable]) async throws -> Value
|
||||||
) {
|
) {
|
||||||
self.destinationKey = destinationKey
|
self.destinationKey = destinationKey
|
||||||
self.sourceKeys = sourceKeys
|
self.sourceKeys = sourceKeys
|
||||||
|
|||||||
@ -3,12 +3,12 @@ import Foundation
|
|||||||
public struct DefaultTransformingMigration<SourceValue: Codable & Sendable, DestinationValue: Codable & Sendable>: TransformingMigration {
|
public struct DefaultTransformingMigration<SourceValue: Codable & Sendable, DestinationValue: Codable & Sendable>: TransformingMigration {
|
||||||
public let destinationKey: StorageKey<DestinationValue>
|
public let destinationKey: StorageKey<DestinationValue>
|
||||||
public let sourceKey: StorageKey<SourceValue>
|
public let sourceKey: StorageKey<SourceValue>
|
||||||
public let transformAction: (SourceValue) async throws -> DestinationValue
|
public let transformAction: @Sendable (SourceValue) async throws -> DestinationValue
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
destinationKey: StorageKey<DestinationValue>,
|
destinationKey: StorageKey<DestinationValue>,
|
||||||
sourceKey: StorageKey<SourceValue>,
|
sourceKey: StorageKey<SourceValue>,
|
||||||
transform: @escaping (SourceValue) async throws -> DestinationValue
|
transform: @escaping @Sendable (SourceValue) async throws -> DestinationValue
|
||||||
) {
|
) {
|
||||||
self.destinationKey = destinationKey
|
self.destinationKey = destinationKey
|
||||||
self.sourceKey = sourceKey
|
self.sourceKey = sourceKey
|
||||||
|
|||||||
@ -9,8 +9,12 @@ public struct AnyStorageMigration: Sendable {
|
|||||||
|
|
||||||
public init<M: StorageMigration>(_ migration: M) {
|
public init<M: StorageMigration>(_ migration: M) {
|
||||||
self.destinationDescriptor = .from(migration.destinationKey)
|
self.destinationDescriptor = .from(migration.destinationKey)
|
||||||
self.shouldMigrateAction = migration.shouldMigrate
|
self.shouldMigrateAction = { @Sendable router, context in
|
||||||
self.migrateAction = migration.migrate
|
try await migration.shouldMigrate(using: router, context: context)
|
||||||
|
}
|
||||||
|
self.migrateAction = { @Sendable router, context in
|
||||||
|
try await migration.migrate(using: router, context: context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func shouldMigrate(using router: StorageRouter, context: MigrationContext) async throws -> Bool {
|
public func shouldMigrate(using router: StorageRouter, context: MigrationContext) async throws -> Bool {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user