Skip to content

Build your personal knowledge base with Trilium Notes

added migration to fix notePosition to always step in 10 increments

zadam5f6dd1848929
diff --git a/db/demo.zip b/db/demo.zip
index 1aee4a863d..29a6c9fccf 100644
Binary files a/db/demo.zip and b/db/demo.zip differ
diff --git a/db/migrations/0170__fix_branch_ordering.js b/db/migrations/0170__fix_branch_ordering.js
new file mode 100644
index 0000000000..ad9c219a36
--- /dev/null
+++ b/db/migrations/0170__fix_branch_ordering.js
@@ -0,0 +1,14 @@
+const repository = require('../../src/services/repository');
+const sql = require('../../src/services/sql');
+
+module.exports = () => {
+ for (const note of repository.getEntities("SELECT * FROM notes")) {
+ let position = 0;
+
+ for (const branch of note.getChildBranches()) {
+ sql.execute(`UPDATE branches SET notePosition = ? WHERE branchId = ?`, [position, branch.branchId]);
+
+ position += 10;
+ }
+ }
+};
diff --git a/src/services/app_info.js b/src/services/app_info.js
index e710bd6b63..02d3644d3d 100644
--- a/src/services/app_info.js
+++ b/src/services/app_info.js
@@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
-const APP_DB_VERSION = 169;
+const APP_DB_VERSION = 170;
const SYNC_VERSION = 16;
const CLIPPER_PROTOCOL_VERSION = "1.0";