mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	migration fixes
This commit is contained in:
		
							parent
							
								
									620bed73bb
								
							
						
					
					
						commit
						0ddaa8f5c2
					
				| @ -1,7 +0,0 @@ | ||||
| -- "randomize" branchIds so it's clear user should not rely on them | ||||
| UPDATE branches SET branchId = '7LSsI2FnZPW2' WHERE parentNoteId = 'hidden' AND noteId = 'search'; | ||||
| UPDATE branches SET branchId = 'wEcmxk4CNC7G' WHERE parentNoteId = 'singles' AND noteId = 'globalnotemap'; | ||||
| UPDATE branches SET branchId = '191uVR6Cu6fA' WHERE parentNoteId = 'hidden' AND noteId = 'sqlconsole'; | ||||
| UPDATE branches SET branchId = 'OjX5Phxp6A4N' WHERE parentNoteId = 'root' AND noteId = 'hidden'; | ||||
| UPDATE branches SET branchId = 'glNBYFYZRH8P' WHERE parentNoteId = 'hidden' AND noteId = 'bulkaction'; | ||||
| UPDATE branches SET branchId = 'cAT25wvGMg3K' WHERE parentNoteId = 'root' AND noteId = 'share'; | ||||
							
								
								
									
										6
									
								
								db/migrations/0198__rename_branchIds.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								db/migrations/0198__rename_branchIds.sql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| UPDATE branches SET branchId = '_hidden__search' WHERE parentNoteId = 'hidden' AND noteId = 'search'; | ||||
| UPDATE branches SET branchId = 'root__globalNoteMap' WHERE parentNoteId = 'singles' AND noteId = 'globalnotemap'; | ||||
| UPDATE branches SET branchId = '_hidden__sqlConsole' WHERE parentNoteId = 'hidden' AND noteId = 'sqlconsole'; | ||||
| UPDATE branches SET branchId = 'root__hidden' WHERE parentNoteId = 'root' AND noteId = 'hidden'; | ||||
| UPDATE branches SET branchId = '_hidden__bulkAction' WHERE parentNoteId = 'hidden' AND noteId = 'bulkaction'; | ||||
| UPDATE branches SET branchId = '_hidden__share' WHERE parentNoteId = 'root' AND noteId = 'share'; | ||||
| @ -1,2 +1,2 @@ | ||||
| DELETE FROM branches WHERE noteId = '_globalNoteMap' AND parentNoteId != 'singles'; -- make sure there are no clones which would fail at the next line | ||||
| DELETE FROM branches WHERE noteId = '_globalNoteMap' AND parentNoteId != 'singles' AND parentNoteId != '_hidden'; -- make sure there are no clones which would fail at the next line | ||||
| UPDATE branches SET parentNoteId = '_hidden' WHERE noteId = '_globalNoteMap'; | ||||
|  | ||||
| @ -232,6 +232,10 @@ class Branch extends AbstractEntity { | ||||
|             this.isExpanded = false; | ||||
|         } | ||||
| 
 | ||||
|         if (!this.prefix?.trim()) { | ||||
|             this.prefix = null; | ||||
|         } | ||||
| 
 | ||||
|         this.utcDateModified = dateUtils.utcNowDateTime(); | ||||
| 
 | ||||
|         super.beforeSaving(); | ||||
|  | ||||
| @ -78,14 +78,14 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) { | ||||
|         return validationResult; | ||||
|     } | ||||
| 
 | ||||
|     new Branch({ | ||||
|     const branch = new Branch({ | ||||
|         noteId: noteId, | ||||
|         parentNoteId: parentNoteId, | ||||
|         prefix: prefix, | ||||
|         isExpanded: 0 | ||||
|     }).save(); | ||||
| 
 | ||||
|     log.info(`Ensured note '${noteId}' is in parent note '${parentNoteId}' with prefix '${prefix}'`); | ||||
|     log.info(`Ensured note '${noteId}' is in parent note '${parentNoteId}' with prefix '${branch.prefix}'`); | ||||
| 
 | ||||
|     return { success: true }; | ||||
| } | ||||
|  | ||||
| @ -296,7 +296,7 @@ class ConsistencyChecks { | ||||
|                     for (const branch of branches.slice(1)) { | ||||
|                         branch.markAsDeleted(); | ||||
| 
 | ||||
|                         logFix(`Removing branch '${branch.branchId}' since it's parent-child duplicate of branch '${origBranch.branchId}'`); | ||||
|                         logFix(`Removing branch '${branch.branchId}' since it's a parent-child duplicate of branch '${origBranch.branchId}'`); | ||||
|                     } | ||||
| 
 | ||||
|                     this.reloadNeeded = true; | ||||
|  | ||||
| @ -244,7 +244,7 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) { | ||||
|     } | ||||
| 
 | ||||
|     let note = becca.notes[item.id]; | ||||
|     let branch = becca.branches[item.id]; | ||||
|     let branch; | ||||
| 
 | ||||
|     if (!note) { | ||||
|         ({note, branch} = noteService.createNewNote({ | ||||
| @ -255,6 +255,8 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) { | ||||
|             content: '', | ||||
|             ignoreForbiddenParents: true | ||||
|         })); | ||||
|     } else { | ||||
|         branch = note.getParentBranches().find(branch => branch.parentNoteId === parentNoteId); | ||||
|     } | ||||
| 
 | ||||
|     const attrs = [...(item.attributes || [])]; | ||||
|  | ||||
| @ -22,7 +22,7 @@ async function migrate() { | ||||
|     } | ||||
| 
 | ||||
|     fs.readdirSync(resourceDir.MIGRATIONS_DIR).forEach(file => { | ||||
|         const match = file.match(/([0-9]{4})__([a-zA-Z0-9_ ]+)\.(sql|js)/); | ||||
|         const match = file.match(/^([0-9]{4})__([a-zA-Z0-9_ ]+)\.(sql|js)$/); | ||||
| 
 | ||||
|         if (match) { | ||||
|             const dbVersion = parseInt(match[1]); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam