From c49c69f82410029921910cf93b5d515d92fc3c40 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 12 Nov 2019 21:32:35 +0100 Subject: [PATCH] fix migration script --- .../a2c75661-f9e2-478f-a69f-6a9409e69997.xml | 31 ------------------- db/migrations/0151__add_isErased_to_note.sql | 2 +- src/services/consistency_checks.js | 13 +++++--- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml index 526cb2feb..af7acccd2 100644 --- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml +++ b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml @@ -57,7 +57,6 @@ 1 apiTokenId - 1 @@ -126,25 +125,20 @@ 1 attributeId - 1 noteId - name value - name - value - attributeId @@ -206,21 +200,17 @@ value 1 branchId - 1 noteId parentNoteId - noteId - parentNoteId - branchId @@ -251,7 +241,6 @@ parentNoteId 1 noteId - 1 @@ -282,7 +271,6 @@ parentNoteId 1 noteRevisionId - 1 @@ -367,28 +355,22 @@ parentNoteId 1 noteRevisionId - 1 noteId - utcDateLastEdited - utcDateCreated - dateLastEdited - dateCreated - noteRevisionId @@ -470,36 +452,28 @@ parentNoteId 1 noteId - 1 title - type - isDeleted - dateCreated - dateModified - utcDateCreated - utcDateModified - noteId @@ -540,7 +514,6 @@ parentNoteId 1 name - 1 @@ -576,7 +549,6 @@ parentNoteId 1 noteId - 1 @@ -597,7 +569,6 @@ parentNoteId 1 sourceId - 1 @@ -660,12 +631,10 @@ parentNoteId entityName entityId - 1 utcSyncDate - id diff --git a/db/migrations/0151__add_isErased_to_note.sql b/db/migrations/0151__add_isErased_to_note.sql index 9cd860697..ae996c6ab 100644 --- a/db/migrations/0151__add_isErased_to_note.sql +++ b/db/migrations/0151__add_isErased_to_note.sql @@ -20,7 +20,7 @@ DROP TABLE notes; ALTER TABLE notes_mig RENAME TO notes; UPDATE notes SET isErased = 1 WHERE isDeleted = 1 -AND 1=(SELECT CASE content WHEN NULL THEN 1 ELSE 0 END FROM note_contents WHERE note_contents.noteId = notes.noteId); +AND 1=(SELECT CASE WHEN content IS NULL THEN 1 ELSE 0 END FROM note_contents WHERE note_contents.noteId = notes.noteId); CREATE INDEX `IDX_notes_isDeleted` ON `notes` (`isDeleted`); CREATE INDEX `IDX_notes_title` ON `notes` (`title`); diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 73f6725fd..520d1cdf9 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -32,12 +32,17 @@ async function findAndFixIssues(query, fixerCb) { for (const res of results) { const autoFix = await optionsService.getOptionBool('autoFixConsistencyIssues'); - await fixerCb(res, autoFix); + try { + await fixerCb(res, autoFix); - if (autoFix) { - fixedIssues = true; + if (autoFix) { + fixedIssues = true; + } else { + unrecoveredConsistencyErrors = true; + } } - else { + catch (e) { + logError(`Fixer failed with ${e.message} ${e.stack}`); unrecoveredConsistencyErrors = true; } }