fix migration so that only really changed notes are updated, #1254

This commit is contained in:
zadam 2020-10-03 20:51:14 +02:00
parent 8313116b7f
commit 71894c34aa

View file

@ -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}`);