My app has 2 very simple models which gives me errors whenever I reload the data:
CoreData: error: Error: Persistent History (3) has to be truncated due to the following entities being removed: (
RecipePersistentModel,
Ingredient
)
CoreData: warning: Warning: Dropping Indexes for Persistent History
CoreData: warning: Warning: Dropping Transactions prior to 3 for Persistent History
CoreData: warning: Warning: Dropping Changes prior to TransactionID 3 for Persistent History
SQLite error code:1, 'no such table: ZINGREDIENT'
CoreData: error: exception during newFetchedPKsForSourceID: I/O error for database at
These are the models:
final class RecipePersistentModel: Hashable {
@Attribute(.unique) let id: String
var title: String
var desc: String
@Relationship(deleteRule: .cascade)
var ingredients: [Ingredient] = []
init(id: String, title: String, desc: String, ingredients: [Ingredient]) {
self.id = id
self.title = title
self.desc = desc
self.ingredients = ingredients
}
}
final class Ingredient: Hashable {
@Attribute(.unique) let id: String
var name: String
var count: Int
init(id: String, name: String, count: Int) {
self.id = id
self.name = name
self.count = count
}
}
The app is on iOS 17 only. I'm having hard time working with SwiftData so far, whats wrong with this code?