Skip to content

Commit

Permalink
avniproject/avni-client#1161 | Create migation to remove individuals …
Browse files Browse the repository at this point in the history
…with lowestAddressLevel = null

(cherry picked from commit a205093)
  • Loading branch information
Suhas Vishwanath authored and himeshr committed Nov 3, 2023
1 parent fbbdffd commit 08c49ce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const entities = [
function createRealmConfig() {
return {
//order is important, should be arranged according to the dependency
schemaVersion: 179,
schemaVersion: 180,
onMigration: function (oldDB, newDB) {
console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
if (oldDB.schemaVersion < 10) {
Expand Down Expand Up @@ -797,6 +797,15 @@ function createRealmConfig() {
}
});
}
if (oldDB.schemaVersion < 180) {
General.logDebug("Migration180", "Migration execution started")
const individualsOfInterest = newDB.objects(Individual.schema.name).filtered("lowestAddressLevel = null");
_.forEach(individualsOfInterest, (individual) => {
General.logDebug("Migration180", "Deleting individual " + individual.uuid)
newDB.delete(individual)
})
General.logDebug("Migration180", "Migration execution completed")
}
},
};
}
Expand Down

0 comments on commit 08c49ce

Please sign in to comment.