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

[C-API] Support for new SchemaMode::HardResetFile

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • Q1-23FY
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently Java (and later Kotlin) has support for a configuration mode called RealmConfiguration.deleteRealmIfMigrationRequired(). This mode is intended during development as an easy way to iterate on schemas without manually deleting the Realm file.

      This logic is currently implemented in Java as ObjectStore only has partial support for this. The closest ObjectStore has is this

          // If the schema version matches and the only schema changes are new
          // tables and indexes being added or removed, apply the changes to
          // the existing file.
          // Otherwise delete the file and recreate it from scratch.
          // The migration function is not used.
          //
          // This mode allows using schemata with different subsets of tables
          // on different threads, but the tables which are shared must be
          // identical.
          ResetFile,
      

      Which on the surface does the right thing, but it has problematic consequences, namely that old data are still left in the file which makes it hard to reason about from an end-user perspective and doesn't play nice with another feature that Java has (Config::initialization_function Which populates the Realm the first time the Realm is created).

      I would like to propose the following:

      1. Rename SchemaMode::ResetFile to SchemaMode::SoftResetFile
      2. Introduce a new schema mode: SchemaMode::HardResetFile which will delete the file on any migration.

            Assignee:
            jorgen.edelbo@mongodb.com Jørgen Edelbo
            Reporter:
            christian.melchior@mongodb.com Christian Melchior (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: