Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-731

Automatic handling of backlinks when migrating to EmbeddedObject

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      Summary

      Migrating a table from non-embedded to embedded is not really easy and obvious in the user-facing SDKs.
      This could be improved by automating the main problems and making the migration easier for the user.

      Motivation

      When migrating a table from non-embedded to embedded users do struggle to get it right because they have to deal with two cases:

      The struggle itself has two reasons:

      While allowing the latter for the special case of migration would partial solve this, I'd like to propose the following changes to solve all those problems at once.

      Goals

      When applying the post migration changes we ensure the following during https://github.com/realm/realm-core/blob/master/src/realm/object-store/object_store.cpp#L832:

      • Objects with too many backlinks get duplicated and assigned one to each backlink so that we automatically end up with objects with only one backlink.
      • Orphaned objects will be deleted. This will only happen when a flag is explicitly set to make sure users consciously confirm that data should be deleted.

      User-facing API

      • Adding a new option deleteOrphanedObjects to the migration, type bool. In the SDKs this would probably make most sense in RealmConfiguration since the MigrationBlock and the DeleteFilesOnMigration flag already live there. In Core this might probably be best situated in ObjectSchema next to IsEmbedded itself.
      • Default would be false so that it does not influence any existing migrations.

            Assignee:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Reporter:
            dominic.frei@mongodb.com Dominic Frei (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: