mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix DB migration and consistency issues
This commit is contained in:
parent
48684d0509
commit
3db2f6784d
@ -1,3 +1,9 @@
|
|||||||
|
-- first fix deleted status of existing images
|
||||||
|
UPDATE note_images SET isDeleted = 1 WHERE noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1);
|
||||||
|
|
||||||
|
-- we don't need set data to null because table is going to be dropped anyway and we want image size into attribute
|
||||||
|
UPDATE images SET isDeleted = 1 WHERE imageId NOT IN (SELECT imageId FROM note_images WHERE isDeleted = 0);
|
||||||
|
|
||||||
-- allow null for note content (for deleted notes)
|
-- allow null for note content (for deleted notes)
|
||||||
CREATE TABLE IF NOT EXISTS "notes_mig" (
|
CREATE TABLE IF NOT EXISTS "notes_mig" (
|
||||||
`noteId` TEXT NOT NULL,
|
`noteId` TEXT NOT NULL,
|
||||||
|
1
db/migrations/0117__fix_attributes_of_deleted_notes.sql
Normal file
1
db/migrations/0117__fix_attributes_of_deleted_notes.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
UPDATE attributes SET isDeleted = 1 WHERE noteId IN (SELECT noteId FROM notes WHERE isDeleted = 1);
|
1
db/migrations/0118__fix_broken_relations.sql
Normal file
1
db/migrations/0118__fix_broken_relations.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
UPDATE attributes SET isDeleted = 1 WHERE type = 'relation' AND value NOT IN (SELECT noteId FROM notes WHERE notes.isDeleted = 0);
|
@ -3,7 +3,7 @@
|
|||||||
const build = require('./build');
|
const build = require('./build');
|
||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
|
|
||||||
const APP_DB_VERSION = 116;
|
const APP_DB_VERSION = 118;
|
||||||
const SYNC_VERSION = 2;
|
const SYNC_VERSION = 2;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -275,8 +275,9 @@ async function runAllChecks() {
|
|||||||
LEFT JOIN notes AS sourceNote ON sourceNote.noteId = links.noteId AND sourceNote.isDeleted = 0
|
LEFT JOIN notes AS sourceNote ON sourceNote.noteId = links.noteId AND sourceNote.isDeleted = 0
|
||||||
LEFT JOIN notes AS targetNote ON targetNote.noteId = links.noteId AND targetNote.isDeleted = 0
|
LEFT JOIN notes AS targetNote ON targetNote.noteId = links.noteId AND targetNote.isDeleted = 0
|
||||||
WHERE
|
WHERE
|
||||||
sourceNote.noteId IS NULL
|
links.isDeleted = 0
|
||||||
OR targetNote.noteId IS NULL`,
|
AND (sourceNote.noteId IS NULL
|
||||||
|
OR targetNote.noteId IS NULL)`,
|
||||||
"Link to source/target note link is broken", errorList);
|
"Link to source/target note link is broken", errorList);
|
||||||
|
|
||||||
await runSyncRowChecks("notes", "noteId", errorList);
|
await runSyncRowChecks("notes", "noteId", errorList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user