added migration to fix notePosition to always step in 10 increments

This commit is contained in:
zadam
2020-09-23 23:08:58 +02:00
parent a577485e42
commit 5f6dd18489
3 changed files with 15 additions and 1 deletions

View File

@@ -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;
}
}
};