Closed devethan closed 2 months ago
In most cases, schema migration can happen automatically. At least if you have simple schema changes, and you don't need to change any objects.
In your case, I would change the code to
export const CURRENT_REALM_SCHEMA_VERSION = 6;
export function onMigration( oldRealm: Realm, newRealm: Realm ) {
const oldSchemaVersion = oldRealm.schemaVersion;
const migration = [
() => { /* do */ },
() => { /* do */ },
];
for (let ver = oldSchemaVersion; ver < CURRENT_REALM_SCHEMA_VERSION; ver++) {
migration[ver]();
}
};
Documentation on how to change an object model might be useful.
@kneth Could you please explain/list schema changes that require migration and what are the schema changes that trigger automatic migration?
Problem
Hi, I'd like to know what is YOUR the best practice to write codes for migration statement.
I've manageed to that like below codes,
If the user install the version which has schemaVersion 2 and then update to the version has schemaVersion 6, the migration statement will executed from case 2 to 5.
Solution
No response
Alternatives
No response
How important is this improvement for you?
Feature would mainly be used with