Skip to content

Commit

Permalink
added migration to add excludeFromTreeMap for journal subtrees
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Sep 23, 2021
1 parent fabf24a commit b041d08
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 17 deletions.
15 changes: 15 additions & 0 deletions db/migrations/0184__add_excludeFromTreeMap_to_journal.js
@@ -0,0 +1,15 @@
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('excludeFromTreeMap', "", true);
}
}
});
};
54 changes: 44 additions & 10 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -48,7 +48,7 @@
"helmet": "4.6.0",
"html": "1.0.0",
"html2plaintext": "2.1.2",
"http-proxy-agent": "4.0.1",
"http-proxy-agent": "5.0.0",
"https-proxy-agent": "5.0.0",
"image-type": "4.1.0",
"ini": "2.0.0",
Expand All @@ -59,7 +59,7 @@
"jsdom": "17.0.0",
"mime-types": "2.1.32",
"multer": "1.4.3",
"node-abi": "3.0.0",
"node-abi": "3.1.0",
"open": "8.2.1",
"portscanner": "2.2.0",
"rand-token": "1.0.1",
Expand Down
2 changes: 0 additions & 2 deletions src/becca/entities/note.js
Expand Up @@ -233,8 +233,6 @@ class Note extends AbstractEntity {
}
}

console.log("POJO update", pojo);

sql.upsert("note_contents", "noteId", pojo);

const hash = utils.hash(this.noteId + "|" + pojo.content.toString());
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/services/froca.js
Expand Up @@ -174,7 +174,7 @@ class Froca {
return;
}

const searchResultNoteIds = await server.get('special-notes/search-note/' + note.noteId);
const searchResultNoteIds = await server.get('search-note/' + note.noteId);

if (!Array.isArray(searchResultNoteIds)) {
throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);
Expand Down
2 changes: 1 addition & 1 deletion src/services/app_info.js
Expand Up @@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');

const APP_DB_VERSION = 183;
const APP_DB_VERSION = 184;
const SYNC_VERSION = 21;
const CLIPPER_PROTOCOL_VERSION = "1.0";

Expand Down
9 changes: 8 additions & 1 deletion src/services/migration.js
Expand Up @@ -32,7 +32,14 @@ async function migrate() {
// backup before attempting migration
await backupService.backupNow("before-migration");

const currentDbVersion = parseInt(optionService.getOption('dbVersion'));
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.");

utils.crash();
return;
}

fs.readdirSync(resourceDir.MIGRATIONS_DIR).forEach(file => {
const match = file.match(/([0-9]{4})__([a-zA-Z0-9_ ]+)\.(sql|js)/);
Expand Down

0 comments on commit b041d08

Please sign in to comment.