diff --git a/db/migrations/0172__migrate_saved_notes.js b/db/migrations/0172__migrate_saved_search_notes.js similarity index 100% rename from db/migrations/0172__migrate_saved_notes.js rename to db/migrations/0172__migrate_saved_search_notes.js diff --git a/db/migrations/0181__fix_entityChanges_isSynced.sql b/db/migrations/0181__fix_entityChanges_isSynced.sql new file mode 100644 index 000000000..22a933b03 --- /dev/null +++ b/db/migrations/0181__fix_entityChanges_isSynced.sql @@ -0,0 +1,5 @@ +UPDATE entity_changes SET isSynced = ( + SELECT options.isSynced + FROM options + WHERE options.name = entity_changes.entityId +) WHERE entityName = 'options'; diff --git a/src/services/app_info.js b/src/services/app_info.js index 11a3a1eaf..070570165 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 = 180; +const APP_DB_VERSION = 181; const SYNC_VERSION = 19; const CLIPPER_PROTOCOL_VERSION = "1.0"; diff --git a/src/services/sync_update.js b/src/services/sync_update.js index 6a33e37de..0c2a241ba 100644 --- a/src/services/sync_update.js +++ b/src/services/sync_update.js @@ -1,4 +1,5 @@ const sql = require('./sql'); +const log = require('./log'); const entityChangesService = require('./entity_changes.js'); const eventService = require('./events'); const entityConstructor = require('../entities/entity_constructor'); @@ -6,6 +7,18 @@ const entityConstructor = require('../entities/entity_constructor'); function updateEntity(entityChange, entity, sourceId) { // can be undefined for options with isSynced=false if (!entity) { + if (entityChange.isSynced) { + if (entityChange.isErased) { + entityChangesService.addEntityChange(entityChange, sourceId); + } + else { + log.info(`Encountered synced non-erased entity change without entity: ${JSON.stringify(entityChange)}`); + } + } + else if (entityChange.entityName !== 'options') { + log.info(`Encountered unsynced non-option entity change without entity: ${JSON.stringify(entityChange)}`); + } + return; }