I’ve began growing app with SwiftData and determined to maneuver to VersionedSchema just lately and it simply fails when I attempt to add a brand new model of a schema with Code=134504 "Can not use staged migration with an unknown coordinator mannequin model."
Once I initially added model and named it v1, all labored positive, however making any modifications to future schemas carry the identical error. (proper now I am on V2, however I simply dropped information on my growth units).
import Basis
import SwiftData
enum SchemaV2: VersionedSchema {
static var versionIdentifier: Schema.Model = Schema.Model(2, 0, 0)
static var fashions: [any PersistentModel.Type] {
[..., cardModel.self]
}
...different fashions...
@Mannequin
remaining class cardModel {
var financial institution: bankModel
var identify: String?
init(financial institution: bankModel, identify: String? = nil) {
self.financial institution = financial institution
self.identify = identify
}
}
}
SchemaV3:
import Basis
import SwiftData
enum SchemaV3: VersionedSchema {
static var versionIdentifier: Schema.Model = Schema.Model(3, 0, 0)
static var fashions: [any PersistentModel.Type] {
[..., cardModel.self]
}
...different fashions...
@Mannequin
remaining class cardModel {
var financial institution: bankModel
var identify: String?
var rewardType: RewardType?
init(financial institution: bankModel,
identify: String? = nil,
rewardType: RewardType? = .money
) {
self.financial institution = financial institution
self.identify = identify
self.rewardType = rewardType
}
}
}
MigrationPlan:
import SwiftData
enum MigrationPlan: SchemaMigrationPlan {
static var levels: [MigrationStage] {
[
MigrateV1toV2, MigrateV2toV3
]
}
static var schemas: [any VersionedSchema.Type] {
[SchemaV1.self, SchemaV2.self, SchemaV3.self
]
}
static let MigrateV1toV2 = MigrationStage.light-weight(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self
)
// I need to use a customized migration right here, however even light-weight fails
static let MigrateV2toV3 = MigrationStage.light-weight(
fromVersion: SchemaV2.self,
toVersion: SchemaV3.self)
}
Not too certain how can I proceed, since I’ve versionIdentifier in each schema and they’re semver. Clear builds, Mac reload, beta Xcode had been tried as properly with no luck. Looking for unknown coordinator mannequin model
did not assist a lot.
p.s.I initialise SchemaV1 like this:
enum SchemaV1: VersionedSchema {
static var versionIdentifier = Schema.Model(1, 0, 0) // Additionally tried to make use of such type with no luck: public static var versionIdentifier: Schema.Model {.init(1, 0, 0)}
static var fashions: [any PersistentModel.Type] {
[..., cardModel.self]
}
...fashions...
}