diff --git a/bin/tpl/anonymize-database.sql b/bin/tpl/anonymize-database.sql index bcd506f82..c99e56e7a 100644 --- a/bin/tpl/anonymize-database.sql +++ b/bin/tpl/anonymize-database.sql @@ -1,6 +1,6 @@ UPDATE etapi_tokens SET tokenHash = 'API token hash value'; -UPDATE notes SET title = 'title' WHERE title NOT IN ('root', 'hidden', 'share'); +UPDATE notes SET title = 'title' WHERE title NOT IN ('root', '_hidden', '_share'); UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; diff --git a/db/migrations/0199__rename_ids.sql b/db/migrations/0199__rename_ids.sql new file mode 100644 index 000000000..76b7e128f --- /dev/null +++ b/db/migrations/0199__rename_ids.sql @@ -0,0 +1,49 @@ +UPDATE notes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE note_contents SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE note_revisions SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE branches SET branchId = '_globalNoteMap' WHERE branchId = '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' WHERE noteId = 'bulkaction'; +UPDATE note_contents SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE note_revisions SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE branches SET branchId = '_bulkAction' WHERE branchId = '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' 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 branchId = '_sqlConsole' WHERE branchId = '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' 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' WHERE noteId = 'hidden'; +UPDATE branches SET branchId = '_hidden' WHERE branchId = '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' 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 branchId = '_search' WHERE branchId = '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'; diff --git a/db/migrations/0199__rename_noteIds.sql b/db/migrations/0199__rename_noteIds.sql deleted file mode 100644 index 675f6d0c4..000000000 --- a/db/migrations/0199__rename_noteIds.sql +++ /dev/null @@ -1,35 +0,0 @@ -UPDATE notes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE notes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE notes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE note_contents SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE note_contents SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE note_contents SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE note_revisions SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE note_revisions SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE note_revisions SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE branches SET branchId = 'globalNoteMap' WHERE branchId = 'globalnotemap'; -UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction'; -UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole'; - -UPDATE branches SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE branches SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE branches SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap'; -UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction'; -UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole'; - -UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE attributes SET value = 'globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; -UPDATE attributes SET value = 'bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; -UPDATE attributes SET value = 'sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; - -UPDATE entity_changes SET entityId = 'globalNoteMap' WHERE entityId = 'globalnotemap'; -UPDATE entity_changes SET entityId = 'bulkAction' WHERE entityId = 'bulkaction'; -UPDATE entity_changes SET entityId = 'sqlConsole' WHERE entityId = 'sqlconsole'; diff --git a/db/migrations/0201__move_share_under_hidden.sql b/db/migrations/0201__move_share_under_hidden.sql index 68e9eb747..46c1e9979 100644 --- a/db/migrations/0201__move_share_under_hidden.sql +++ b/db/migrations/0201__move_share_under_hidden.sql @@ -1 +1 @@ -UPDATE branches SET parentNoteId = 'hidden' WHERE branchId = 'share'; +UPDATE branches SET parentNoteId = '_hidden' WHERE branchId = '_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 index 69363c527..5c5f42812 100644 --- a/db/migrations/0202__move_global_note_map_under_hidden.sql +++ b/db/migrations/0202__move_global_note_map_under_hidden.sql @@ -1 +1,2 @@ -UPDATE branches SET parentNoteId = 'hidden' WHERE noteId = 'globalNoteMap'; +DELETE FROM branches WHERE noteId = '_globalNoteMap' AND parentNoteId != 'singles'; -- 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/0206__delete_search_and_sql_console_history.js b/db/migrations/0206__delete_search_and_sql_console_history.js index 1c6568f95..089d3f58d 100644 --- a/db/migrations/0206__delete_search_and_sql_console_history.js +++ b/db/migrations/0206__delete_search_and_sql_console_history.js @@ -10,7 +10,7 @@ module.exports = () => { // deleting just branches because they might be cloned (and therefore saved) also outside of the hidden subtree - const searchRoot = becca.getNote('search'); + const searchRoot = becca.getNote('_search'); for (const searchBranch of searchRoot.getChildBranches()) { const searchNote = searchBranch.getNote(); @@ -20,7 +20,7 @@ module.exports = () => { } } - const sqlConsoleRoot = becca.getNote('sqlConsole'); + const sqlConsoleRoot = becca.getNote('_sqlConsole'); for (const sqlConsoleBranch of sqlConsoleRoot.getChildBranches()) { const sqlConsoleNote = sqlConsoleBranch.getNote(); diff --git a/db/migrations/0207__rename_search_and_sql_console.sql b/db/migrations/0207__rename_search_and_sql_console.sql index 79398fd4c..b751faeda 100644 --- a/db/migrations/0207__rename_search_and_sql_console.sql +++ b/db/migrations/0207__rename_search_and_sql_console.sql @@ -1,2 +1,2 @@ -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 +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 index 52089ee6b..0261ab173 100644 --- a/db/migrations/0208__remove_archived_from_hidden.js +++ b/db/migrations/0208__remove_archived_from_hidden.js @@ -6,7 +6,7 @@ module.exports = () => { cls.init(() => { beccaLoader.load(); - for (const label of becca.getNote('hidden').getLabels('archived')) { + for (const label of becca.getNote('_hidden').getLabels('archived')) { label.markAsDeleted('0208__remove_archived_from_hidden'); } }); diff --git a/package-lock.json b/package-lock.json index b6e2c904e..701daf498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "trilium", "version": "0.57.5", "hasInstallScript": true, "license": "AGPL-3.0-only", diff --git a/src/becca/entities/branch.js b/src/becca/entities/branch.js index 263298e6c..f97fe0ec3 100644 --- a/src/becca/entities/branch.js +++ b/src/becca/entities/branch.js @@ -129,7 +129,7 @@ class Branch extends AbstractEntity { * @returns {boolean} */ get isWeak() { - return ['share', 'lbBookmarks'].includes(this.parentNoteId); + return ['_share', 'lbBookmarks'].includes(this.parentNoteId); } /** @@ -211,7 +211,7 @@ class Branch extends AbstractEntity { let maxNotePos = 0; for (const childBranch of this.parentNote.getChildBranches()) { - if (maxNotePos < childBranch.notePosition && childBranch.branchId !== 'hidden') { + if (maxNotePos < childBranch.notePosition && childBranch.branchId !== '_hidden') { maxNotePos = childBranch.notePosition; } } diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js index 2652d788a..c6dabba29 100644 --- a/src/becca/entities/note.js +++ b/src/becca/entities/note.js @@ -904,7 +904,7 @@ class Note extends AbstractEntity { function addSubtreeNotesInner(note, parentNote = null) { // share can be removed after 0.57 since it will be put under hidden - if (note.noteId === 'hidden' || note.noteId === 'share') { + if (note.noteId === '_hidden' || note.noteId === '_share') { return; } @@ -1342,7 +1342,7 @@ class Note extends AbstractEntity { } isLaunchBarConfig() { - return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId); + return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId); } isOptions() { diff --git a/src/public/app/components/entrypoints.js b/src/public/app/components/entrypoints.js index f82e2d361..b1706f357 100644 --- a/src/public/app/components/entrypoints.js +++ b/src/public/app/components/entrypoints.js @@ -95,7 +95,7 @@ export default class Entrypoints extends Component { logoutCommand() { const $logoutForm = $('