| 
									
										
										
										
											2022-12-27 14:44:28 +01:00
										 |  |  | module.exports = () => { | 
					
						
							|  |  |  |     const cls = require("../../src/services/cls"); | 
					
						
							|  |  |  |     const beccaLoader = require("../../src/becca/becca_loader"); | 
					
						
							|  |  |  |     const becca = require("../../src/becca/becca"); | 
					
						
							| 
									
										
										
										
											2023-03-17 22:14:50 +01:00
										 |  |  |     const log = require("../../src/services/log"); | 
					
						
							| 
									
										
										
										
											2022-12-27 14:44:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     cls.init(() => { | 
					
						
							|  |  |  |         beccaLoader.load(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const hidden = becca.getNote("_hidden"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-17 22:14:50 +01:00
										 |  |  |         if (!hidden) { | 
					
						
							|  |  |  |             log.info("MIGRATION 212: no _hidden note, skipping."); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-27 14:44:28 +01:00
										 |  |  |         for (const noteId of hidden.getSubtreeNoteIds({includeHidden: true})) { | 
					
						
							|  |  |  |             if (noteId.startsWith("_")) { // is "named" note
 | 
					
						
							|  |  |  |                 const note = becca.getNote(noteId); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 for (const attr of note.getOwnedAttributes()) { | 
					
						
							|  |  |  |                     attr.markAsDeleted("0212__delete_all_attributes_of_named_notes"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | }; |