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
  • Loading branch information
Suhas Vishwanath committed Nov 1, 2023
1 parent 796e907 commit a205093
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 @@ -186,7 +186,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 @@ -795,6 +795,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 a205093

Please sign in to comment.