From c8ba07a4aecc45b5ce017a116da5d1cdbded167d Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 23 Nov 2019 11:13:57 +0100 Subject: [PATCH] fix migration script in case of not fully consistent database (missing note_contents for note). closes #717 --- db/migrations/0152__add_contentLength_to_note.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrations/0152__add_contentLength_to_note.sql b/db/migrations/0152__add_contentLength_to_note.sql index 4d4cf0c8c..60e38df86 100644 --- a/db/migrations/0152__add_contentLength_to_note.sql +++ b/db/migrations/0152__add_contentLength_to_note.sql @@ -20,7 +20,7 @@ SELECT noteId, title, -1, isProtected, type, mime, hash, isDeleted, isErased, da DROP TABLE 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_title` ON `notes` (`title`);