mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
fix recent notes (db & sync version increase)
This commit is contained in:
@@ -4,8 +4,8 @@ const build = require('./build');
|
||||
const packageJson = require('../../package');
|
||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||
|
||||
const APP_DB_VERSION = 135;
|
||||
const SYNC_VERSION = 8;
|
||||
const APP_DB_VERSION = 136;
|
||||
const SYNC_VERSION = 9;
|
||||
|
||||
module.exports = {
|
||||
appVersion: packageJson.version,
|
||||
|
||||
@@ -396,7 +396,7 @@ async function findSyncRowsIssues() {
|
||||
await runSyncRowChecks("note_contents", "noteId");
|
||||
await runSyncRowChecks("note_revisions", "noteRevisionId");
|
||||
await runSyncRowChecks("branches", "branchId");
|
||||
await runSyncRowChecks("recent_notes", "branchId");
|
||||
await runSyncRowChecks("recent_notes", "noteId");
|
||||
await runSyncRowChecks("attributes", "attributeId");
|
||||
await runSyncRowChecks("api_tokens", "apiTokenId");
|
||||
await runSyncRowChecks("options", "name");
|
||||
|
||||
@@ -246,7 +246,7 @@ const primaryKeys = {
|
||||
"note_contents": "noteId",
|
||||
"branches": "branchId",
|
||||
"note_revisions": "noteRevisionId",
|
||||
"recent_notes": "branchId",
|
||||
"recent_notes": "noteId",
|
||||
"api_tokens": "apiTokenId",
|
||||
"options": "name",
|
||||
"attributes": "attributeId",
|
||||
|
||||
@@ -28,8 +28,8 @@ async function addOptionsSync(name, sourceId) {
|
||||
await addEntitySync("options", name, sourceId);
|
||||
}
|
||||
|
||||
async function addRecentNoteSync(branchId, sourceId) {
|
||||
await addEntitySync("recent_notes", branchId, sourceId);
|
||||
async function addRecentNoteSync(noteId, sourceId) {
|
||||
await addEntitySync("recent_notes", noteId, sourceId);
|
||||
}
|
||||
|
||||
async function addLinkSync(linkId, sourceId) {
|
||||
@@ -91,7 +91,7 @@ async function fillAllSyncRows() {
|
||||
await fillSyncRows("note_contents", "noteId");
|
||||
await fillSyncRows("branches", "branchId");
|
||||
await fillSyncRows("note_revisions", "noteRevisionId");
|
||||
await fillSyncRows("recent_notes", "branchId");
|
||||
await fillSyncRows("recent_notes", "noteId");
|
||||
await fillSyncRows("attributes", "attributeId");
|
||||
await fillSyncRows("api_tokens", "apiTokenId");
|
||||
await fillSyncRows("links", "linkId");
|
||||
|
||||
@@ -148,13 +148,13 @@ async function updateOptions(entity, sourceId) {
|
||||
}
|
||||
|
||||
async function updateRecentNotes(entity, sourceId) {
|
||||
const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE branchId = ?", [entity.branchId]);
|
||||
const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE noteId = ?", [entity.noteId]);
|
||||
|
||||
if (orig === null || orig.utcDateCreated < entity.utcDateCreated) {
|
||||
await sql.transactional(async () => {
|
||||
await sql.replace('recent_notes', entity);
|
||||
|
||||
await syncTableService.addRecentNoteSync(entity.branchId, sourceId);
|
||||
await syncTableService.addRecentNoteSync(entity.noteId, sourceId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user