I’ve an app with some SwiftData Fashions. One is known as Tapas and it has a relationship with TapasAsana. One Tapas has many Asanas, so I linked them with a relationship. This all works fantastic thus far.
Now I simply forgot one property in TapasAsana. I examine gentle migration and it must be simple to simply add that property. However irrespective of if I add it on the finish or in the midst of the properties it breaks my app. The app compiles and runs, however the outdated Knowledge would not get proven anymore. And cretaing new ones within the app additionally will not work, attempting to straight create a TapasAsana crashes the App.
That is the code for the TapasAsana Mannequin, the one the place I’m including a property. The brand new property is known as recoupCount.
import Basis
import SwiftData
@Mannequin
class TapasAsana {
var title: String
var length: Int /// How lengthy to execute every day
var timeToday: Int /// Time executed already at this time
var recoupCount: Int /// What number of recoups this Asana has.
var polar: Bool /// If it's a polar Asana
var doneToday: Bool /// Whether it is accomplished at this time
init(title: String = "Padahastasana", length: Int = 5 * 60, timeToday: Int = 0, recoupCount: Int = 0, polar: Bool = false, doneToday: Bool = false) {
self.title = title
self.length = length
self.timeToday = timeToday
self.recoupCount = recoupCount
self.polar = polar
self.doneToday = doneToday
}
}
I attempted to simply add the brand new Property, so as to add it on the final place to not confuse SwiftData with the order. However none of that works. I did not strive extra as a result of studying about migration stated the straightforward add of a property ought to work tremendous.