I had to implement this migration for an object that was stored in DataStore using Protobuf and Kotlinx Serialisable on Android. The original object looked like this:
@Serializable
data class Assignment(val state: State)
@Serializable
sealed interface State {
@Serializable
data object Pending : State
// More implementations
}
The new object was supposed to look like this:
@Serializable
sealed interface State {
@Serializable
data class Pending(val id: String) : State
// More implementations
}
Continue reading “Fixing Android DataStore migration from a data object to a data class”