Нужно ли выполнять блокировку миграции при обновлении @PersistableEnum?IOS

Программируем под IOS
Ответить
Гость
 Нужно ли выполнять блокировку миграции при обновлении @PersistableEnum?

Сообщение Гость »


I have a realm model setup like this:

Код: Выделить всё

enum RealmEnumExample: String, Codable, PersistableEnum {     case hot, cold, cloudy, rainy } final class RealmExample: Object, ObjectKeyIdentifiable {     @Persisted(primaryKey: true) var id: Int     @Persisted var weather: RealmEnumExample          init(id: Int, weather: RealmEnumExample) {                  super.init()         self.id = id         self.weather = weather     }          override init() {         super.init()     } } 
If I remove cold and cloudy from RealmNumExample and add warm do I need to perform a realm migration block in addition to updating the schema version? Realm documentation says that when adding and removing properties realm automatically does the migration for you but it is not clear with PersistableEnums in cases like these. When would renaming a property be relevant in this example? Lets say I "renamed" cloudy to warm wouldn't that be the same as removing cloudy and adding warm, therefore, not needing a migration block in that case as well and only needing to update the schema version?

I am confused on when it would be appropriate to resort to "renaming" properties in this scenario and doing a migration block or allowing realm to do the migration if it is handling it as adding and removing properties.


Источник: https://stackoverflow.com/questions/781 ... stableenum
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»