Skip to content

Commit

Permalink
fix old migration to avoid unique constraints problems, closes #3447
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Dec 22, 2022
1 parent 5a3882f commit e05e4be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
12 changes: 4 additions & 8 deletions db/migrations/0192__add_memberId_to_entity_changes.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
DROP TABLE entity_changes;
-- not preserving the data because of https://github.com/zadam/trilium/issues/3447

CREATE TABLE IF NOT EXISTS "entity_changes" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL,
`entityId` TEXT NOT NULL,
Expand All @@ -11,13 +14,6 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`utcDateChanged` TEXT NOT NULL
);

INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, componentId, instanceId, isSynced, utcDateChanged)
SELECT id, entityName, entityId, hash, isErased, changeId, '', '', isSynced, utcDateChanged FROM entity_changes;

DROP TABLE entity_changes;

ALTER TABLE mig_entity_changes RENAME TO entity_changes;

CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" (
`entityName`,
`entityId`
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e05e4be

Please sign in to comment.