fix note revision's isErased initial value after migration

This commit is contained in:
zadam
2019-11-11 23:26:46 +01:00
parent 4cda661c1b
commit 4ba7e74b58
2 changed files with 23 additions and 0 deletions

View File

@@ -334,6 +334,27 @@ async function findLogicIssues() {
AND content IS NOT NULL`,
({noteId}) => `Note ${noteId} content is not null even though the note is erased`);
await findAndFixIssues(`
SELECT noteId, noteRevisionId
FROM notes
JOIN note_revisions USING(noteId)
WHERE
notes.isErased = 1
AND note_revisions.isErased = 0`,
async ({noteId, noteRevisionId}, autoFix) => {
if (autoFix) {
const noteRevision = await repository.getNoteRevision(noteRevisionId);
noteRevision.isErased = true;
await noteRevision.setContent(null);
await noteRevision.save();
logFix(`Note revision ${noteRevisionId} has been erased since its note ${noteId} is also erased.`);
}
else {
logError(`Note revision ${noteRevisionId} is not erased even though note ${noteId} is erased.`);
}
});
await findAndFixIssues(`
SELECT noteRevisionId
FROM note_revisions