mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/beta' into beta
# Conflicts: # package-lock.json
This commit is contained in:
		
						commit
						e7d57bc08f
					
				| @ -1 +0,0 @@ | ||||
| module.exports = () => console.log("NOOP, moved to migration 0189"); | ||||
| @ -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'; | ||||
| @ -1,2 +0,0 @@ | ||||
| ALTER TABLE branches DROP COLUMN utcDateCreated; | ||||
| ALTER TABLE options DROP COLUMN utcDateCreated; | ||||
| @ -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` | ||||
|     ); | ||||
| @ -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 | ||||
| ); | ||||
| @ -1 +0,0 @@ | ||||
| DELETE FROM options WHERE name = 'username'; | ||||
| @ -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'; | ||||
| @ -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]); | ||||
|     } | ||||
| }; | ||||
| @ -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` | ||||
|     ); | ||||
| @ -1 +0,0 @@ | ||||
| CREATE INDEX `IDX_entity_changes_changeId` ON `entity_changes` (`changeId`); | ||||
| @ -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); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -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'; | ||||
| @ -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'; | ||||
| @ -1 +0,0 @@ | ||||
| module.exports = () => console.log("NOOP, increased because of protected notes IV change"); | ||||
| @ -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; | ||||
| @ -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'; | ||||
| @ -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); | ||||
|     }); | ||||
| }; | ||||
| @ -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'; | ||||
| @ -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'; | ||||
| @ -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'; | ||||
| @ -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'); | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -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'; | ||||
| @ -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'); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -1,2 +0,0 @@ | ||||
| UPDATE notes SET title = 'SQL Console History' WHERE noteId = '_sqlConsole'; | ||||
| UPDATE notes SET title = 'Search History' WHERE noteId = '_search'; | ||||
| @ -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'); | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -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'; | ||||
| @ -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}`); | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -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; | ||||
| @ -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"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -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}`); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| }; | ||||
| @ -1 +0,0 @@ | ||||
| UPDATE branches SET notePosition = notePosition - 999899999 WHERE parentNoteId = 'root' AND notePosition > 999999999; | ||||
| @ -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' | ||||
|     ); | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam