mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
migration workaround for corrupted index in entity_changes table, closes #2534
This commit is contained in:
parent
7495777d97
commit
c102089731
@ -1,13 +1,3 @@
|
||||
-- delete duplicates https://github.com/zadam/trilium/issues/2534
|
||||
DELETE FROM entity_changes WHERE isErased = 0 AND 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,
|
||||
@ -23,7 +13,17 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
|
||||
INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
|
||||
SELECT id, entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
|
||||
|
||||
DROP TABLE entity_changes;
|
||||
-- delete duplicates https://github.com/zadam/trilium/issues/2534
|
||||
DELETE FROM mig_entity_changes WHERE isErased = 0 AND id IN (
|
||||
SELECT id FROM mig_entity_changes ec
|
||||
WHERE (
|
||||
SELECT COUNT(*) FROM mig_entity_changes
|
||||
WHERE ec.entityName = mig_entity_changes.entityName
|
||||
AND ec.entityId = mig_entity_changes.entityId
|
||||
) > 1
|
||||
);
|
||||
|
||||
DROP TABLE entity_changes;
|
||||
|
||||
ALTER TABLE mig_entity_changes RENAME TO entity_changes;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user