diff --git a/db/migrations/0158__add_isSynced_to_sync.sql b/db/migrations/0158__add_isSynced_to_sync.sql index a2d978bc1..2c419b9a0 100644 --- a/db/migrations/0158__add_isSynced_to_sync.sql +++ b/db/migrations/0158__add_isSynced_to_sync.sql @@ -6,8 +6,8 @@ CREATE TABLE IF NOT EXISTS "sync_mig" ( `isSynced` INTEGER default 0 not null, `utcSyncDate` TEXT NOT NULL); -INSERT INTO sync_mig (entityName, entityId, sourceId, isSynced, utcSyncDate) -SELECT entityName, entityId, sourceId, 1, utcSyncDate FROM sync; +INSERT INTO sync_mig (id, entityName, entityId, sourceId, isSynced, utcSyncDate) +SELECT id, entityName, entityId, sourceId, 1, utcSyncDate FROM sync; DROP TABLE sync; diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 705ab02e6..d09aebb0b 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -51,7 +51,7 @@ class ConsistencyChecks { childToParents[childNoteId].push(parentNoteId); } - function checkTreeCycle(noteId, path) { + const checkTreeCycle = (noteId, path) => { if (noteId === 'root') { return; } @@ -75,7 +75,7 @@ class ConsistencyChecks { checkTreeCycle(parentNoteId, newPath); } } - } + }; const noteIds = Object.keys(childToParents); diff --git a/src/services/repository.js b/src/services/repository.js index 85cad2cd3..98effc1a6 100644 --- a/src/services/repository.js +++ b/src/services/repository.js @@ -112,7 +112,7 @@ async function updateEntity(entity) { if (entity.isChanged) { const isSynced = entityName !== 'options' || entity.isSynced; - await syncTableService.addEntitySync(entityName, primaryKey, isSynced); + await syncTableService.addEntitySync(entityName, primaryKey, null, isSynced); if (!cls.isEntityEventsDisabled()) { const eventPayload = { diff --git a/src/services/sync_table.js b/src/services/sync_table.js index 8134849a8..dec81fd19 100644 --- a/src/services/sync_table.js +++ b/src/services/sync_table.js @@ -10,13 +10,13 @@ const cls = require('./cls'); let maxSyncId = 0; -async function insertEntitySync(entityName, entityId, sourceId, isSynced) { +async function insertEntitySync(entityName, entityId, sourceId = null, isSynced = true) { const sync = { entityName: entityName, entityId: entityId, utcSyncDate: dateUtils.utcNowDateTime(), sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(), - isSynced: isSynced + isSynced: isSynced ? 1 : 0 }; sync.id = await sql.replace("sync", sync); @@ -26,7 +26,7 @@ async function insertEntitySync(entityName, entityId, sourceId, isSynced) { return sync; } -async function addEntitySync(entityName, entityId, sourceId, isSynced = true) { +async function addEntitySync(entityName, entityId, sourceId, isSynced) { const sync = await insertEntitySync(entityName, entityId, sourceId, isSynced); cls.addSyncRow(sync);