diff --git a/db/migrations/0184__NOOP.js b/db/migrations/0184__NOOP.js deleted file mode 100644 index 9ad8902db..000000000 --- a/db/migrations/0184__NOOP.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => console.log("NOOP, moved to migration 0189"); diff --git a/db/migrations/0185__migrate_black_theme_to_dark.sql b/db/migrations/0185__migrate_black_theme_to_dark.sql deleted file mode 100644 index 7285f6eb7..000000000 --- a/db/migrations/0185__migrate_black_theme_to_dark.sql +++ /dev/null @@ -1,4 +0,0 @@ --- black theme has been removed, dark is closest replacement -UPDATE options SET value = 'dark' WHERE name = 'theme' AND value = 'black'; - -UPDATE options SET value = 'light' WHERE name = 'theme' AND value = 'white'; diff --git a/db/migrations/0186__drop_branches_options_utcDateCreated.sql b/db/migrations/0186__drop_branches_options_utcDateCreated.sql deleted file mode 100644 index b678f64a4..000000000 --- a/db/migrations/0186__drop_branches_options_utcDateCreated.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE branches DROP COLUMN utcDateCreated; -ALTER TABLE options DROP COLUMN utcDateCreated; diff --git a/db/migrations/0187__add_changeId_to_entity_changes.sql b/db/migrations/0187__add_changeId_to_entity_changes.sql deleted file mode 100644 index 1fdadbec7..000000000 --- a/db/migrations/0187__add_changeId_to_entity_changes.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( - `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `entityName` TEXT NOT NULL, - `entityId` TEXT NOT NULL, - `hash` TEXT NOT NULL, - `isErased` INT NOT NULL, - `changeId` TEXT NOT NULL, - `sourceId` TEXT NOT NULL, - `isSynced` INTEGER NOT NULL, - `utcDateChanged` TEXT NOT NULL -); - -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; - --- 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; - -CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" ( - `entityName`, - `entityId` - ); diff --git a/db/migrations/0188__set_hidden_branchId.sql b/db/migrations/0188__set_hidden_branchId.sql deleted file mode 100644 index 8ef8116d7..000000000 --- a/db/migrations/0188__set_hidden_branchId.sql +++ /dev/null @@ -1,8 +0,0 @@ -UPDATE branches SET branchId = 'hidden' where branchId = ( - SELECT branchId FROM branches - WHERE parentNoteId = 'root' - AND noteId = 'hidden' - AND isDeleted = 0 - ORDER BY utcDateModified - LIMIT 1 -); diff --git a/db/migrations/0189__delete_username_option.sql b/db/migrations/0189__delete_username_option.sql deleted file mode 100644 index 439a201e6..000000000 --- a/db/migrations/0189__delete_username_option.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM options WHERE name = 'username'; diff --git a/db/migrations/0190__change_to_etapi_tokens.sql b/db/migrations/0190__change_to_etapi_tokens.sql deleted file mode 100644 index a9ea45fe7..000000000 --- a/db/migrations/0190__change_to_etapi_tokens.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE IF NOT EXISTS "etapi_tokens" -( - etapiTokenId TEXT PRIMARY KEY NOT NULL, - name TEXT NOT NULL, - tokenHash TEXT NOT NULL, - utcDateCreated TEXT NOT NULL, - utcDateModified TEXT NOT NULL, - isDeleted INT NOT NULL DEFAULT 0); - -INSERT INTO etapi_tokens (etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted) -SELECT apiTokenId, 'Trilium Sender', token, utcDateCreated, utcDateCreated, isDeleted FROM api_tokens; - -DROP TABLE api_tokens; - -UPDATE entity_changes SET entityName = 'etapi_tokens' WHERE entityName = 'api_tokens'; diff --git a/db/migrations/0191__hash_tokens.js b/db/migrations/0191__hash_tokens.js deleted file mode 100644 index d799a7283..000000000 --- a/db/migrations/0191__hash_tokens.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = () => { - const sql = require('../../src/services/sql'); - const crypto = require('crypto'); - - for (const {etapiTokenId, token} of sql.getRows("SELECT etapiTokenId, tokenHash AS token FROM etapi_tokens")) { - const tokenHash = crypto.createHash('sha256').update(token).digest('base64'); - - sql.execute(`UPDATE etapi_tokens SET tokenHash = ? WHERE etapiTokenId = ?`, [tokenHash, etapiTokenId]); - } -}; \ No newline at end of file diff --git a/db/migrations/0192__add_memberId_to_entity_changes.sql b/db/migrations/0192__add_memberId_to_entity_changes.sql deleted file mode 100644 index 89d2904c5..000000000 --- a/db/migrations/0192__add_memberId_to_entity_changes.sql +++ /dev/null @@ -1,20 +0,0 @@ -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, - `hash` TEXT NOT NULL, - `isErased` INT NOT NULL, - `changeId` TEXT NOT NULL, - `componentId` TEXT NOT NULL, - `instanceId` TEXT NOT NULL, - `isSynced` INTEGER NOT NULL, - `utcDateChanged` TEXT NOT NULL -); - -CREATE UNIQUE INDEX `IDX_entityChanges_entityName_entityId` ON "entity_changes" ( - `entityName`, - `entityId` - ); diff --git a/db/migrations/0193__add_index_to_changeId.sql b/db/migrations/0193__add_index_to_changeId.sql deleted file mode 100644 index 3bc24efb9..000000000 --- a/db/migrations/0193__add_index_to_changeId.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX `IDX_entity_changes_changeId` ON `entity_changes` (`changeId`); diff --git a/db/migrations/0194__add_excludeFromNoteMap_to_journal.js b/db/migrations/0194__add_excludeFromNoteMap_to_journal.js deleted file mode 100644 index 1cc602960..000000000 --- a/db/migrations/0194__add_excludeFromNoteMap_to_journal.js +++ /dev/null @@ -1,15 +0,0 @@ -const becca = require('../../src/becca/becca'); -const beccaLoader = require('../../src/becca/becca_loader'); -const cls = require('../../src/services/cls'); - -module.exports = () => { - cls.init(() => { - beccaLoader.load(); - - for (const note of Object.values(becca.notes)) { - if (note.hasLabel('calendarRoot')) { - note.addLabel('excludeFromNoteMap', "", true); - } - } - }); -}; diff --git a/db/migrations/0195__remove_recent_notes_from_entity_changes.sql b/db/migrations/0195__remove_recent_notes_from_entity_changes.sql deleted file mode 100644 index 834db7fe9..000000000 --- a/db/migrations/0195__remove_recent_notes_from_entity_changes.sql +++ /dev/null @@ -1,2 +0,0 @@ --- removing potential remnants of recent notes in entity changes, see https://github.com/zadam/trilium/issues/2842 -DELETE FROM entity_changes WHERE entityName = 'recent_notes'; diff --git a/db/migrations/0196__rename_bulk_actions.sql b/db/migrations/0196__rename_bulk_actions.sql deleted file mode 100644 index ad4c5febe..000000000 --- a/db/migrations/0196__rename_bulk_actions.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE attributes SET value = replace(value, 'setLabelValue', 'updateLabelValue') WHERE name = 'action' AND type = 'label'; -UPDATE attributes SET value = replace(value, 'setRelationTarget', 'updateRelationTarget') WHERE name = 'action' AND type = 'label'; diff --git a/db/migrations/0197__NOOP.js b/db/migrations/0197__NOOP.js deleted file mode 100644 index c7bdf54ac..000000000 --- a/db/migrations/0197__NOOP.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => console.log("NOOP, increased because of protected notes IV change"); diff --git a/db/migrations/0198__rename_branchIds.sql b/db/migrations/0198__rename_branchIds.sql deleted file mode 100644 index 5b32eb51c..000000000 --- a/db/migrations/0198__rename_branchIds.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE branches SET branchId = '_hidden__search' WHERE parentNoteId = 'hidden' AND noteId = 'search' AND isDeleted = 0; -UPDATE branches SET branchId = 'root__globalNoteMap' WHERE parentNoteId = 'singles' AND noteId = 'globalnotemap' AND isDeleted = 0; -UPDATE branches SET branchId = '_hidden__sqlConsole' WHERE parentNoteId = 'hidden' AND noteId = 'sqlconsole' AND isDeleted = 0; -UPDATE branches SET branchId = 'root__hidden' WHERE parentNoteId = 'root' AND noteId = 'hidden' AND isDeleted = 0; -UPDATE branches SET branchId = '_hidden__bulkAction' WHERE parentNoteId = 'hidden' AND noteId = 'bulkaction' AND isDeleted = 0; -UPDATE branches SET branchId = '_hidden__share' WHERE parentNoteId = 'root' AND noteId = 'share' AND isDeleted = 0; diff --git a/db/migrations/0199__rename_ids.sql b/db/migrations/0199__rename_ids.sql deleted file mode 100644 index ca1ed273e..000000000 --- a/db/migrations/0199__rename_ids.sql +++ /dev/null @@ -1,53 +0,0 @@ -UPDATE notes SET noteId = '_globalNoteMap', title = 'Note Map' WHERE noteId = 'globalnotemap'; -UPDATE note_contents SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE note_revisions SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE branches SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE branches SET parentNoteId = '_globalNoteMap' WHERE parentNoteId = 'globalnotemap'; -UPDATE attributes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE attributes SET value = '_globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; -UPDATE entity_changes SET entityId = '_globalNoteMap' WHERE entityId = 'globalnotemap'; - -UPDATE notes SET noteId = '_bulkAction', title = 'Bulk Action' WHERE noteId = 'bulkaction'; -UPDATE note_contents SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; -UPDATE note_revisions SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; -UPDATE branches SET parentNoteId = '_bulkAction' WHERE parentNoteId = 'bulkaction'; -UPDATE branches SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; -UPDATE attributes SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; -UPDATE attributes SET value = '_bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; -UPDATE entity_changes SET entityId = '_bulkAction' WHERE entityId = 'bulkaction'; - -UPDATE notes SET noteId = '_sqlConsole', title = 'SQL Console History' WHERE noteId = 'sqlconsole'; -UPDATE note_contents SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; -UPDATE note_revisions SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; -UPDATE branches SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; -UPDATE branches SET parentNoteId = '_sqlConsole' WHERE parentNoteId = 'sqlconsole'; -UPDATE attributes SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; -UPDATE attributes SET value = '_sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; -UPDATE entity_changes SET entityId = '_sqlConsole' WHERE entityId = 'sqlconsole'; - -UPDATE notes SET noteId = '_hidden', title = 'Hidden Notes' WHERE noteId = 'hidden'; -UPDATE note_contents SET noteId = '_hidden' WHERE noteId = 'hidden'; -UPDATE note_revisions SET noteId = '_hidden' WHERE noteId = 'hidden'; -UPDATE branches SET noteId = '_hidden', prefix = NULL WHERE noteId = 'hidden'; -UPDATE branches SET parentNoteId = '_hidden' WHERE parentNoteId = 'hidden'; -UPDATE attributes SET noteId = '_hidden' WHERE noteId = 'hidden'; -UPDATE attributes SET value = '_hidden' WHERE type = 'relation' AND value = 'hidden'; -UPDATE entity_changes SET entityId = '_hidden' WHERE entityId = 'hidden'; - -UPDATE notes SET noteId = '_search', title = 'Search History' WHERE noteId = 'search'; -UPDATE note_contents SET noteId = '_search' WHERE noteId = 'search'; -UPDATE note_revisions SET noteId = '_search' WHERE noteId = 'search'; -UPDATE branches SET noteId = '_search' WHERE noteId = 'search'; -UPDATE branches SET parentNoteId = '_search' WHERE parentNoteId = 'search'; -UPDATE attributes SET noteId = '_search' WHERE noteId = 'search'; -UPDATE attributes SET value = '_search' WHERE type = 'relation' AND value = 'search'; -UPDATE entity_changes SET entityId = '_search' WHERE entityId = 'search'; - -UPDATE notes SET noteId = '_share', title = 'Shared Notes' WHERE noteId = 'share'; -UPDATE note_contents SET noteId = '_share' WHERE noteId = 'share'; -UPDATE note_revisions SET noteId = '_share' WHERE noteId = 'share'; -UPDATE branches SET noteId = '_share' WHERE noteId = 'share'; -UPDATE branches SET parentNoteId = '_share' WHERE parentNoteId = 'share'; -UPDATE attributes SET noteId = '_share' WHERE noteId = 'share'; -UPDATE attributes SET value = '_share' WHERE type = 'relation' AND value = 'share'; -UPDATE entity_changes SET entityId = '_share' WHERE entityId = 'share'; diff --git a/db/migrations/0200__create_hidden_subtree.js b/db/migrations/0200__create_hidden_subtree.js deleted file mode 100644 index 6d283d715..000000000 --- a/db/migrations/0200__create_hidden_subtree.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = () => { - const hiddenSubtreeService = require('../../src/services/hidden_subtree'); - const cls = require("../../src/services/cls"); - const beccaLoader = require("../../src/becca/becca_loader"); - - cls.init(() => { - beccaLoader.load(); - // make sure the hidden subtree exists since the subsequent migrations we will move some existing notes into it (share...) - // in previous releases hidden subtree was created lazily - hiddenSubtreeService.checkHiddenSubtree(true); - }); -}; diff --git a/db/migrations/0201__move_share_under_hidden.sql b/db/migrations/0201__move_share_under_hidden.sql deleted file mode 100644 index 84c71b34a..000000000 --- a/db/migrations/0201__move_share_under_hidden.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM branches WHERE noteId = '_share' AND parentNoteId != 'root' AND parentNoteId != '_hidden'; -- delete all other branches of _share if any -UPDATE branches SET parentNoteId = '_hidden' WHERE noteId = '_share'; diff --git a/db/migrations/0202__move_global_note_map_under_hidden.sql b/db/migrations/0202__move_global_note_map_under_hidden.sql deleted file mode 100644 index 0b634f69f..000000000 --- a/db/migrations/0202__move_global_note_map_under_hidden.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM branches WHERE noteId = '_globalNoteMap' AND parentNoteId != 'singles' AND parentNoteId != '_hidden'; -- make sure there are no clones which would fail at the next line -UPDATE branches SET parentNoteId = '_hidden' WHERE noteId = '_globalNoteMap'; diff --git a/db/migrations/0203__delete_singles_special_note.sql b/db/migrations/0203__delete_singles_special_note.sql deleted file mode 100644 index 817d6fcc8..000000000 --- a/db/migrations/0203__delete_singles_special_note.sql +++ /dev/null @@ -1,6 +0,0 @@ -DELETE FROM branches WHERE noteId = 'singles'; -DELETE FROM notes WHERE noteId = 'singles'; -DELETE FROM note_contents WHERE noteId = 'singles'; -DELETE FROM note_revisions WHERE noteId = 'singles'; -DELETE FROM attributes WHERE noteId = 'singles'; -DELETE FROM entity_changes WHERE entityId = 'singles'; diff --git a/db/migrations/0204__migrate_bookmarks_to_clones.js b/db/migrations/0204__migrate_bookmarks_to_clones.js deleted file mode 100644 index 6b180a446..000000000 --- a/db/migrations/0204__migrate_bookmarks_to_clones.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = () => { - const cls = require("../../src/services/cls"); - const cloningService = require("../../src/services/cloning"); - const beccaLoader = require("../../src/becca/becca_loader"); - const becca = require("../../src/becca/becca"); - - cls.init(() => { - beccaLoader.load(); - - for (const attr of becca.findAttributes('label','bookmarked')) { - cloningService.toggleNoteInParent(true, attr.noteId, '_lbBookmarks'); - - attr.markAsDeleted("0204__migrate_bookmarks_to_clones"); - } - - // bookmarkFolder used to work in 0.57 without the bookmarked label - for (const attr of becca.findAttributes('label','bookmarkFolder')) { - cloningService.toggleNoteInParent(true, attr.noteId, '_lbBookmarks'); - } - }); -}; diff --git a/db/migrations/0205__rename_note_types.sql b/db/migrations/0205__rename_note_types.sql deleted file mode 100644 index 3a056bceb..000000000 --- a/db/migrations/0205__rename_note_types.sql +++ /dev/null @@ -1,3 +0,0 @@ -UPDATE notes SET type = 'relationMap' WHERE type = 'relation-map'; -UPDATE notes SET type = 'noteMap' WHERE type = 'note-map'; -UPDATE notes SET type = 'webView' WHERE type = 'web-view'; diff --git a/db/migrations/0206__delete_search_and_sql_console_history.js b/db/migrations/0206__delete_search_and_sql_console_history.js deleted file mode 100644 index 089d3f58d..000000000 --- a/db/migrations/0206__delete_search_and_sql_console_history.js +++ /dev/null @@ -1,33 +0,0 @@ -// the history was previously not exposed and the fact they were not cleaned up is rather a side-effect than an intention - -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(); - - // deleting just branches because they might be cloned (and therefore saved) also outside of the hidden subtree - - const searchRoot = becca.getNote('_search'); - - for (const searchBranch of searchRoot.getChildBranches()) { - const searchNote = searchBranch.getNote(); - - if (searchNote.type === 'search') { - searchBranch.deleteBranch('0206__delete_search_and_sql_console_history'); - } - } - - const sqlConsoleRoot = becca.getNote('_sqlConsole'); - - for (const sqlConsoleBranch of sqlConsoleRoot.getChildBranches()) { - const sqlConsoleNote = sqlConsoleBranch.getNote(); - - if (sqlConsoleNote.type === 'code' && sqlConsoleNote.mime === 'text/x-sqlite;schema=trilium') { - sqlConsoleBranch.deleteBranch('0206__delete_search_and_sql_console_history'); - } - } - }); -}; diff --git a/db/migrations/0207__rename_search_and_sql_console.sql b/db/migrations/0207__rename_search_and_sql_console.sql deleted file mode 100644 index b751faeda..000000000 --- a/db/migrations/0207__rename_search_and_sql_console.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE notes SET title = 'SQL Console History' WHERE noteId = '_sqlConsole'; -UPDATE notes SET title = 'Search History' WHERE noteId = '_search'; \ No newline at end of file diff --git a/db/migrations/0208__remove_archived_from_hidden.js b/db/migrations/0208__remove_archived_from_hidden.js deleted file mode 100644 index 0261ab173..000000000 --- a/db/migrations/0208__remove_archived_from_hidden.js +++ /dev/null @@ -1,13 +0,0 @@ -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(); - - for (const label of becca.getNote('_hidden').getLabels('archived')) { - label.markAsDeleted('0208__remove_archived_from_hidden'); - } - }); -}; diff --git a/db/migrations/0209__rename_hoisted_labels.sql b/db/migrations/0209__rename_hoisted_labels.sql deleted file mode 100644 index 0ece2c52b..000000000 --- a/db/migrations/0209__rename_hoisted_labels.sql +++ /dev/null @@ -1,5 +0,0 @@ -UPDATE attributes SET name = 'workspaceInbox' WHERE type = 'label' AND name = 'hoistedInbox'; -UPDATE entity_changes SET entityId = 'workspaceInbox' WHERE entityName = 'attributes' AND entityId = 'hoistedInbox'; - -UPDATE attributes SET name = 'workspaceSearchHome' WHERE type = 'label' AND name = 'hoistedSearchHome'; -UPDATE entity_changes SET entityId = 'workspaceSearchHome' WHERE entityName = 'attributes' AND entityId = 'hoistedSearchHome'; diff --git a/db/migrations/0210__consistency_checks.js b/db/migrations/0210__consistency_checks.js deleted file mode 100644 index b29331dbe..000000000 --- a/db/migrations/0210__consistency_checks.js +++ /dev/null @@ -1,24 +0,0 @@ -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"); - const eraseService = require("../../src/services/erase"); - - await cls.init(async () => { - // precaution for the 0211 migration - eraseService.eraseDeletedNotesNow(); - - 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}`); - } - }); -}; diff --git a/db/migrations/0211__rename_branchIds.sql b/db/migrations/0211__rename_branchIds.sql deleted file mode 100644 index be18ec00c..000000000 --- a/db/migrations/0211__rename_branchIds.sql +++ /dev/null @@ -1,12 +0,0 @@ --- case based on isDeleted is needed, otherwise 2 branches (1 deleted, 1 not) might get the same ID -UPDATE entity_changes SET entityId = COALESCE(( - SELECT - CASE isDeleted - WHEN 0 THEN parentNoteId || '_' || noteId - WHEN 1 THEN branchId - END - FROM branches WHERE branchId = entityId -), entityId) -WHERE entityName = 'branches' AND isErased = 0; - -UPDATE branches SET branchId = parentNoteId || '_' || noteId WHERE isDeleted = 0; diff --git a/db/migrations/0212__delete_all_attributes_of_named_notes.js b/db/migrations/0212__delete_all_attributes_of_named_notes.js deleted file mode 100644 index a6f532231..000000000 --- a/db/migrations/0212__delete_all_attributes_of_named_notes.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = () => { - const cls = require("../../src/services/cls"); - const beccaLoader = require("../../src/becca/becca_loader"); - const becca = require("../../src/becca/becca"); - const log = require("../../src/services/log"); - - cls.init(() => { - beccaLoader.load(); - - const hidden = becca.getNote("_hidden"); - - if (!hidden) { - log.info("MIGRATION 212: no _hidden note, skipping."); - return; - } - - 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().slice()) { - attr.markAsDeleted("0212__delete_all_attributes_of_named_notes"); - } - } - } - }); -}; diff --git a/db/migrations/0213__migrate_scripts.js b/db/migrations/0213__migrate_scripts.js deleted file mode 100644 index eed005c1c..000000000 --- a/db/migrations/0213__migrate_scripts.js +++ /dev/null @@ -1,48 +0,0 @@ -module.exports = () => { - const beccaLoader = require("../../src/becca/becca_loader"); - const becca = require("../../src/becca/becca"); - const cls = require("../../src/services/cls"); - const log = require("../../src/services/log"); - - cls.init(() => { - beccaLoader.load(); - - for (const note of Object.values(becca.notes)) { - try { - if (!note.isJavaScript()) { - continue; - } - - if (!note.mime?.endsWith('env=frontend') && !note.mime?.endsWith('env=backend')) { - continue; - } - - const origContent = note.getContent().toString(); - const fixedContent = origContent - .replaceAll("runOnServer", "runOnBackend") - .replaceAll("api.refreshTree()", "") - .replaceAll("addTextToActiveTabEditor", "addTextToActiveContextEditor") - .replaceAll("getActiveTabNote", "getActiveContextNote") - .replaceAll("getActiveTabTextEditor", "getActiveContextTextEditor") - .replaceAll("getActiveTabNotePath", "getActiveContextNotePath") - .replaceAll("getDateNote", "getDayNote") - .replaceAll("utils.unescapeHtml", "unescapeHtml") - .replaceAll("sortNotesByTitle", "sortNotes") - .replaceAll("CollapsibleWidget", "RightPanelWidget") - .replaceAll("TabAwareWidget", "NoteContextAwareWidget") - .replaceAll("TabCachingWidget", "NoteContextAwareWidget") - .replaceAll("NoteContextCachingWidget", "NoteContextAwareWidget"); - - if (origContent !== fixedContent) { - log.info(`Replacing legacy API calls for note '${note.noteId}'`); - - note.saveNoteRevision(); - note.setContent(fixedContent); - } - } - catch (e) { - log.error(`Error during migration to 213 for note '${note.noteId}': ${e.message} ${e.stack}`); - } - } - }); -}; diff --git a/db/migrations/0214__fix_root_children_ordering.sql b/db/migrations/0214__fix_root_children_ordering.sql deleted file mode 100644 index 056a76336..000000000 --- a/db/migrations/0214__fix_root_children_ordering.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE branches SET notePosition = notePosition - 999899999 WHERE parentNoteId = 'root' AND notePosition > 999999999; diff --git a/src/services/migration.js b/src/services/migration.js index 49da65089..58b910d7b 100644 --- a/src/services/migration.js +++ b/src/services/migration.js @@ -9,8 +9,8 @@ const appInfo = require('./app_info'); async function migrate() { const currentDbVersion = getDbVersion(); - if (currentDbVersion < 183) { - log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.47.X first and only then to this version."); + if (currentDbVersion < 214) { + log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version."); utils.crash(); return; @@ -18,9 +18,9 @@ async function migrate() { // backup before attempting migration await backupService.backupNow( - // creating a special backup for versions 0.60.X and older, the changes in 0.61 are major. - currentDbVersion < 214 - ? `before-migration-v${currentDbVersion}` + // creating a special backup for versions 0.60.X, the changes in 0.61 are major. + currentDbVersion === 214 + ? `before-migration-v060` : 'before-migration' ); diff --git a/src/services/tree.js b/src/services/tree.js index 920e26561..adc075f28 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -184,10 +184,8 @@ function sortNotesIfNeeded(parentNoteId) { } const sortReversed = parentNote.getLabelValue('sortDirection')?.toLowerCase() === "desc"; - const sortFoldersFirstLabel = parentNote.getLabel('sortFoldersFirst'); - const sortFoldersFirst = sortFoldersFirstLabel && sortFoldersFirstLabel.value.toLowerCase() !== "false"; - const sortNaturalLabel = parentNote.getLabel('sortNatural'); - const sortNatural = sortNaturalLabel && sortNaturalLabel.value.toLowerCase() !== "false"; + const sortFoldersFirst = parentNote.isLabelTruthy('sortFoldersFirst'); + const sortNatural = parentNote.isLabelTruthy('sortNatural'); const sortLocale = parentNote.getLabelValue('sortLocale'); sortNotes(parentNoteId, sortedLabel.value, sortReversed, sortFoldersFirst, sortNatural, sortLocale);