ReDetection
ReDetection

Reputation: 3186

CoreData to Realm migration and Realm internal migrations as separate steps

I have a production app where data is stored using CoreData framework, and I cannot make a clean break as the data contains only user-generated content and it is not synced to anywhere. I would not like to support CoreData migration to the latest version of the Realm database I have, I would like to migrate CoreData file into the very first version of my realm database, then apply realm migrations. Is this possible?

I thought Realm.Configuration(objectTypes: [MyClass.self, MyOtherClass.self]) will help me, but this only covers the case when new classes added when I have same classes with a different set of properties.

Upvotes: 2

Views: 454

Answers (1)

ReDetection
ReDetection

Reputation: 3186

So far I only have workaround to only add new properties the realm model classes and never delete/change. Also I'll have my own model version, and I'll store it in the some shared entity object like database-wide setting. I'll do my high-level migrations after realm did his own. For simplicity, realm model version and my model version can be kept same.

Once I drop support for CoreData, I can move my migrations into realm migration block and remove obsolete properties from objects.

This approach has a downside that I have to keep old properties for a long time. Same as in synced realms.

Upvotes: 1

Related Questions