-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hidden subtree is now built as "predictable" to avoid duplicating it …
…in sync
- Loading branch information
Showing
13 changed files
with
170 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = async () => { | ||
const cls = require("../../src/services/cls"); | ||
const beccaLoader = require("../../src/becca/becca_loader"); | ||
const log = require("../../src/services/log"); | ||
const consistencyChecks = require("../../src/services/consistency_checks"); | ||
|
||
await cls.init(async () => { | ||
beccaLoader.load(); | ||
|
||
try { | ||
// precaution before running 211 which might produce unique constraint problems if the DB was not consistent | ||
consistencyChecks.runOnDemandChecksWithoutExclusiveLock(true); | ||
} | ||
catch (e) { | ||
// consistency checks might start failing in the future if there's some incompatible migration down the road | ||
// we can optimistically assume the DB is consistent and still continue | ||
log.error(`Consistency checks failed in migration 0210: ${e.message} ${e.stack}`); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- case based on isDeleted is needed, otherwise 2 branches (1 deleted, 1 not) might get the same ID | ||
UPDATE entity_changes SET entityId = ( | ||
SELECT | ||
CASE isDeleted | ||
WHEN 0 THEN parentNoteId || '_' || noteId | ||
WHEN 1 THEN branchId | ||
END | ||
FROM branches WHERE branchId = entityId | ||
) | ||
WHERE entityName = 'branches'; | ||
|
||
UPDATE branches SET branchId = parentNoteId || '_' || noteId WHERE isDeleted = 0; |
21 changes: 21 additions & 0 deletions
21
db/migrations/0212__delete_all_attributes_of_named_notes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = () => { | ||
const cls = require("../../src/services/cls"); | ||
const beccaLoader = require("../../src/becca/becca_loader"); | ||
const becca = require("../../src/becca/becca"); | ||
|
||
cls.init(() => { | ||
beccaLoader.load(); | ||
|
||
const hidden = becca.getNote("_hidden"); | ||
|
||
for (const noteId of hidden.getSubtreeNoteIds({includeHidden: true})) { | ||
if (noteId.startsWith("_")) { // is "named" note | ||
const note = becca.getNote(noteId); | ||
|
||
for (const attr of note.getOwnedAttributes()) { | ||
attr.markAsDeleted("0212__delete_all_attributes_of_named_notes"); | ||
} | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.