forked from CIT/Vmeda.Online
		
	MOBILE-3633 calendar: Fix calendar DB migration
This commit is contained in:
		
							parent
							
								
									1800beed31
								
							
						
					
					
						commit
						16e8b13083
					
				@ -211,15 +211,15 @@ export const CALENDAR_SITE_SCHEMA: CoreSiteSchema = {
 | 
				
			|||||||
                oldTable = 'addon_calendar_events';
 | 
					                oldTable = 'addon_calendar_events';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await db.tableExists(oldTable);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Move the records from the old table.
 | 
					 | 
				
			||||||
            const events = await db.getAllRecords<AddonCalendarEventDBRecord>(oldTable);
 | 
					 | 
				
			||||||
            const promises = events.map((event) => db.insertRecord(newTable, event));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            await Promise.all(promises);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
 | 
					                await db.tableExists(oldTable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Move the records from the old table.
 | 
				
			||||||
 | 
					                const events = await db.getAllRecords<AddonCalendarEventDBRecord>(oldTable);
 | 
				
			||||||
 | 
					                const promises = events.map((event) => db.insertRecord(newTable, event));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await Promise.all(promises);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                db.dropTable(oldTable);
 | 
					                db.dropTable(oldTable);
 | 
				
			||||||
            } catch {
 | 
					            } catch {
 | 
				
			||||||
                // Old table does not exist, ignore.
 | 
					                // Old table does not exist, ignore.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user