Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix migration so that only really changed notes are updated, #1254
zadam71894c34aa47
diff --git a/db/migrations/0169__convert_h1_to_h2.js b/db/migrations/0169__convert_h1_to_h2.jsindex 14696580e4..f1c2cc4bd3 100644--- a/db/migrations/0169__convert_h1_to_h2.js+++ b/db/migrations/0169__convert_h1_to_h2.js@@ -3,13 +3,15 @@ const repository = require('../../src/services/repository');module.exports = () => {for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {try {- let content = note.getContent();+ let origContent = note.getContent();- content = content+ const newContent = origContent.replace(/<h1/ig, "<h2").replace(/<\/h1/ig, "</h2");- note.setContent(content);+ if (newContent !== origContent) {+ note.setContent(newContent);+ }}catch (e) {console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);