diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js index b6be8d619..b97baf4a8 100644 --- a/src/services/hidden_subtree.js +++ b/src/services/hidden_subtree.js @@ -1,6 +1,8 @@ const becca = require("../becca/becca"); const noteService = require("./notes"); const Attribute = require("../becca/entities/attribute.js"); +const log = require("./log"); +const migrationService = require("./migration"); const LBTPL_ROOT = "_lbTplRoot"; const LBTPL_BASE = "_lbTplBase"; @@ -231,6 +233,12 @@ const HIDDEN_SUBTREE_DEFINITION = { }; function checkHiddenSubtree() { + if (!migrationService.isDbUpToDate()) { + // on-delete hook might get triggered during some future migration and cause havoc + log.info("Will not check hidden subtree until migration is finished."); + return; + } + checkHiddenSubtreeRecursively('root', HIDDEN_SUBTREE_DEFINITION); } diff --git a/src/services/migration.js b/src/services/migration.js index 1bda273e4..7bda5bc36 100644 --- a/src/services/migration.js +++ b/src/services/migration.js @@ -119,5 +119,6 @@ async function migrateIfNecessary() { } module.exports = { - migrateIfNecessary + migrateIfNecessary, + isDbUpToDate };