Skip to content

Commit

Permalink
log error instead of throwing on failed migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Aug 17, 2023
1 parent f47f090 commit 38e1431
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/shared/services/IndexedDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class IndexedDb {
// "{ keyPath: "notification.id" }". This resulted in DB v4 either
// having "notificationId" or "notification.id" depending if the visitor
// was new while this version was live.
// DB v5 was create to trigger a migration to fix this bug.
// DB v5 was created to trigger a migration to fix this bug.
db.createObjectStore("NotificationClicked", { keyPath: "notificationId" });
}
if (newDbVersion >= 3 && event.oldVersion < 3) {
Expand Down Expand Up @@ -193,7 +193,12 @@ export default class IndexedDb {
});
cursor.result.continue();
};
cursor.onerror = () => { throw cursor.error; };
cursor.onerror = () => {
// If there is an error getting old records nothing we can do but
// move on. Old table will stay around so an attempt could be made
// later.
console.error("Could not migrate NotificationClicked records", cursor.error);
};
}

// Table rename "NotificationReceived" -> "Outcomes.NotificationReceived"
Expand All @@ -220,7 +225,12 @@ export default class IndexedDb {
.put(cursor.result.value);
cursor.result.continue();
};
cursor.onerror = () => { throw cursor.error; };
cursor.onerror = () => {
// If there is an error getting old records nothing we can do but
// move on. Old table will stay around so an attempt could be made
// later.
console.error("Could not migrate NotificationReceived records", cursor.error);
};
}

/**
Expand Down

0 comments on commit 38e1431

Please sign in to comment.