From 16e8b13083541f643a55c0255e8c4081bcc0e230 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 20 Jan 2021 14:07:53 +0100 Subject: [PATCH] MOBILE-3633 calendar: Fix calendar DB migration --- .../calendar/services/database/calendar.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/addons/calendar/services/database/calendar.ts b/src/addons/calendar/services/database/calendar.ts index fd088c963..711239fbc 100644 --- a/src/addons/calendar/services/database/calendar.ts +++ b/src/addons/calendar/services/database/calendar.ts @@ -211,15 +211,15 @@ export const CALENDAR_SITE_SCHEMA: CoreSiteSchema = { oldTable = 'addon_calendar_events'; } - await db.tableExists(oldTable); - - // Move the records from the old table. - const events = await db.getAllRecords(oldTable); - const promises = events.map((event) => db.insertRecord(newTable, event)); - - await Promise.all(promises); - try { + await db.tableExists(oldTable); + + // Move the records from the old table. + const events = await db.getAllRecords(oldTable); + const promises = events.map((event) => db.insertRecord(newTable, event)); + + await Promise.all(promises); + db.dropTable(oldTable); } catch { // Old table does not exist, ignore.