We are iOS development team and we want to write a paper about Realm Database migrations. We want to explain the process of migration and some our hacks about testing migration code. But we don’t want to misinform our audience. That’s why we ask you to answer some of our questions. If You are interested, we can send draft text of our paper, so you can check if there are any mistakes about Realm Database.
Here are our questions.
- Is it safe to change type of realm field and then use . enumerateObjects () function for data manipulation in migration block? And if I need to change type of field, what would be your recommendation: add new field with new type and delete old field, or just change type of existing field?
Now, as our local tests show, it is safe. But some time ago such kind of changing type of field from Double to Int led us to exceptions in migration block. So, we ask you for your opinion on this question.
- Currently in documentation it’s written, that the only way of writing migration is using straight migration blocks, that migrate our database directly to new version. For example, if I missed some versions of my app, and my db version is 1 and actual app uses version 6, that means I have to write migration block, that migrates db from version 1 directly to version 6? Are there any possibilities to write cascade migrations that will execute one after another and move our db to target version in such a way: 1->2, 2->3, … , 5->6.