fix migration to handle duplicates in entity_changes, #2534

This commit is contained in:
zadam 2022-01-08 22:31:52 +01:00
parent d4d48f3834
commit 75b65c396e

View File

@ -1,3 +1,13 @@
-- delete duplicates https://github.com/zadam/trilium/issues/2534
DELETE FROM entity_changes WHERE id IN (
SELECT id FROM entity_changes ec
WHERE (
SELECT COUNT(*) FROM entity_changes
WHERE ec.entityName = entity_changes.entityName
AND ec.entityId = entity_changes.entityId
) > 1
);
CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL,