Reply to self:
I used custom and now it works
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil, didMigrate: nil
)
static let migrateV2toV3 = MigrationStage.custom(
fromVersion: SchemaV2.self,
toVersion: SchemaV3.self,
willMigrate: nil, didMigrate: nil
)
What I need tho, is a way to completly clear the stores and create a new model structure because I completely changed my models and know nothing is working
Post
Replies
Boosts
Views
Activity
I never use the lightweight migration because it does not work for me, never.
I always use custom with willMigrate: nil and didMigrate: nil
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil, didMigrate: nil
)
static let migrateV2toV3 = MigrationStage.custom(
fromVersion: SchemaV2.self,
toVersion: SchemaV3.self,
willMigrate: nil, didMigrate: nil
)
SwiftData as far as I know is a local SQLite database.
If you call @Query it does load what you specified.
I can not say if it loads ALL data at once, I think it does, tho I hope it uses some clever indexing under the hood.
Custom indexing is currently not available in SwiftData.
If you want to work with the data, (generate graphs), I would async that.
If you want to list the data, try paging and only load x entries.
For know SwiftData seems not build for big data batches.
I did the same as you did AndrewGWalsh. It has also worked well for me but sometimes, when adding new fields to my model and configuring a new schema it breaks completely.
For now I think this is the best way of doing it. I hope it will change tho.