mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-29 03:23:25 +08:00 
			
		
		
		
	Merge branch 'stable'
This commit is contained in:
		
						commit
						ff3f0ee0a0
					
				| @ -20,7 +20,7 @@ SELECT noteId, title, -1, isProtected, type, mime, hash, isDeleted, isErased, da | |||||||
| DROP TABLE notes; | DROP TABLE notes; | ||||||
| ALTER TABLE notes_mig RENAME TO notes; | ALTER TABLE notes_mig RENAME TO notes; | ||||||
| 
 | 
 | ||||||
| UPDATE notes SET contentLength = (SELECT COALESCE(LENGTH(content), 0) FROM note_contents WHERE note_contents.noteId = notes.noteId); | UPDATE notes SET contentLength = COALESCE((SELECT COALESCE(LENGTH(content), 0) FROM note_contents WHERE note_contents.noteId = notes.noteId), -1); | ||||||
| 
 | 
 | ||||||
| CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); | CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); | ||||||
| CREATE INDEX `IDX_notes_title` ON `notes` (`title`); | CREATE INDEX `IDX_notes_title` ON `notes` (`title`); | ||||||
|  | |||||||
| @ -311,6 +311,25 @@ async function findLogicIssues() { | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |     await findAndFixIssues(` | ||||||
|  |                 SELECT notes.noteId | ||||||
|  |                 FROM notes | ||||||
|  |                   LEFT JOIN note_contents USING(noteId) | ||||||
|  |                 WHERE | ||||||
|  |                   note_contents.noteId IS NULL`,
 | ||||||
|  |         async ({noteId}, autoFix) => { | ||||||
|  |             if (autoFix) { | ||||||
|  |                 const note = await repository.getNote(noteId); | ||||||
|  |                 // empty string might be wrong choice for some note types (and protected notes) but it's a best guess
 | ||||||
|  |                 await note.setContent(note.isErased ? null : ''); | ||||||
|  | 
 | ||||||
|  |                 logFix(`Note ${noteId} content was set to empty string since there was no corresponding row`); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 logError(`Note ${noteId} content row does not exist`); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|     await findAndFixIssues(` |     await findAndFixIssues(` | ||||||
|           SELECT noteId |           SELECT noteId | ||||||
|           FROM notes |           FROM notes | ||||||
| @ -321,6 +340,7 @@ async function findLogicIssues() { | |||||||
|         async ({noteId}, autoFix) => { |         async ({noteId}, autoFix) => { | ||||||
|             if (autoFix) { |             if (autoFix) { | ||||||
|                 const note = await repository.getNote(noteId); |                 const note = await repository.getNote(noteId); | ||||||
|  |                 // empty string might be wrong choice for some note types (and protected notes) but it's a best guess
 | ||||||
|                 await note.setContent(''); |                 await note.setContent(''); | ||||||
| 
 | 
 | ||||||
|                 logFix(`Note ${noteId} content was set to empty string since it was null even though it is not deleted`); |                 logFix(`Note ${noteId} content was set to empty string since it was null even though it is not deleted`); | ||||||
| @ -360,6 +380,25 @@ async function findLogicIssues() { | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |     await findAndFixIssues(` | ||||||
|  |                 SELECT note_revisions.noteRevisionId | ||||||
|  |                 FROM note_revisions | ||||||
|  |                 LEFT JOIN note_revision_contents USING(noteRevisionId) | ||||||
|  |                 WHERE note_revision_contents.noteRevisionId IS NULL`,
 | ||||||
|  |         async ({noteRevisionId}, autoFix) => { | ||||||
|  |             if (autoFix) { | ||||||
|  |                 const noteRevision = await repository.getNoteRevision(noteRevisionId); | ||||||
|  |                 await noteRevision.setContent(null); | ||||||
|  |                 noteRevision.isErased = true; | ||||||
|  |                 await noteRevision.save(); | ||||||
|  | 
 | ||||||
|  |                 logFix(`Note revision content ${noteRevisionId} was created and set to erased since it did not exist.`); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 logError(`Note revision content ${noteRevisionId} does not exist`); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|     await findAndFixIssues(` |     await findAndFixIssues(` | ||||||
|           SELECT noteRevisionId |           SELECT noteRevisionId | ||||||
|           FROM note_revisions |           FROM note_revisions | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam