-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write a test for migrating RealmObject -> EmbeddedObject models #2394
Comments
In the related discussion #2393 I've added an explanation about what's going on when migrating to
This will be enabled by adding functionality to take care of orphaned objects ( |
Update: This requires #2408 which itself requires realm/realm-core#4729. |
➤ Dominic Frei commented: Unassigned myself and set it to |
@nirinchev When you say that we need to confirm there's actually a way to do it reliably, it gets me super worried. @DominicFrei @nirinchev Can you confirm that this is something that can be done reliably? The migration samples doesn't contain any of the edge cases. I noticed that there were test cases done here for the dot net SDK https://github.com/realm/realm-dotnet/blob/df/embedded-object-migration-test/Tests/Realm.Tests/Database/MigrationTests.cs#L149-L343 Are these available on the iOS and Android SDK:s as well? Can I use this approach to test that my migration handles all the edge cases? |
@sipersso what SDK are you using? If it's the .NET SDK, then yes, migrating from a RealmObject to EmbeddedObject is possible, but you'll need to manually ensure that there's exactly one link for each target object. It's a bit of a hassle, but should be doable. |
I am using both the iOS SDK(Swift) and The Android/Java SDK. In Kotlin I am doing this to delete orphaned children
On iOS/Swift it is much more complicated since I can't access linking objects from the child during migration
This seems to work, but how can I be sure? Also, it doesn't handle the multiple links. While I don't think that this will happen, I want to make sure that I test for this possibility as well. The migration test example here https://github.com/realm/realm-dotnet/blob/df/embedded-object-migration-test/Tests/Realm.Tests/Database/MigrationTests.cs#L149-L343 seems to cover both cases. How can I write such a test on iOS and Android? The only option I can think of right now is to branch the app off using the old realm configuration and try to create sample realms using that configuration that intentionally creates orphaned objects and multiple backlinks. I need to be 100% certain that the migration doesn't cause crashes at startups for all my customers and now I don't know how to make sure that this will be a smooth transition. It is also a prerequisite for the app to be able to move to Atlas... and make you money ;) |
This was reported by a user in #2393. We should write a test migrating from RealmObject links to EmbeddedObject and confirm that there's actually a way to do it reliably and then work with @MongoCaleb to document it. We should also look into exposing the function to delete all orphaned backlinks mentioned in realm/realm-swift#7145.
The text was updated successfully, but these errors were encountered: