SwiftData complex schema migration
I’ve developed an app some time ago using SwiftData as a backing storage. Recently I needed to update the model, but not merely add or rename a property – these would require a lightweight migration and are done automatically. Boring. No, I needed to take one property and turn it into another one. In my case it was a conversion from date: Date? to dateInt: Int?. Don’t ask me why, it’s a long story but the problem here is that SwiftData wouldn’t know how to automatically convert one to another so I have to show it and do the real complex schema migration. Or do I? ...