mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added isSynced to sync table to allow forward compatibility with 0.41
This commit is contained in:
parent
719f10981e
commit
73bf2dcb02
22
db/migrations/0158__add_isSynced_to_sync.sql
Normal file
22
db/migrations/0158__add_isSynced_to_sync.sql
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS "sync_mig" (
|
||||||
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`entityName` TEXT NOT NULL,
|
||||||
|
`entityId` TEXT NOT NULL,
|
||||||
|
`sourceId` TEXT NOT NULL,
|
||||||
|
`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;
|
||||||
|
|
||||||
|
DROP TABLE sync;
|
||||||
|
|
||||||
|
ALTER TABLE sync_mig RENAME TO sync;
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX `IDX_sync_entityName_entityId` ON `sync` (
|
||||||
|
`entityName`,
|
||||||
|
`entityId`
|
||||||
|
);
|
||||||
|
CREATE INDEX `IDX_sync_utcSyncDate` ON `sync` (
|
||||||
|
`utcSyncDate`
|
||||||
|
);
|
@ -1,9 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const app_info = require('../../services/app_info');
|
const appInfo = require('../../services/app_info');
|
||||||
|
|
||||||
async function getAppInfo() {
|
async function getAppInfo() {
|
||||||
return app_info;
|
return appInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -4,7 +4,7 @@ const build = require('./build');
|
|||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||||
|
|
||||||
const APP_DB_VERSION = 157;
|
const APP_DB_VERSION = 158;
|
||||||
const SYNC_VERSION = 14;
|
const SYNC_VERSION = 14;
|
||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ class ConsistencyChecks {
|
|||||||
${entityName}
|
${entityName}
|
||||||
LEFT JOIN sync ON sync.entityName = '${entityName}' AND entityId = ${key}
|
LEFT JOIN sync ON sync.entityName = '${entityName}' AND entityId = ${key}
|
||||||
WHERE
|
WHERE
|
||||||
sync.id IS NULL AND ` + (entityName === 'options' ? 'isSynced = 1' : '1'),
|
sync.id IS NULL AND ` + (entityName === 'options' ? 'options.isSynced = 1' : '1'),
|
||||||
async ({entityId}) => {
|
async ({entityId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
await syncTableService.addEntitySync(entityName, entityId);
|
await syncTableService.addEntitySync(entityName, entityId);
|
||||||
|
@ -11,7 +11,8 @@ async function insertEntitySync(entityName, entityId, sourceId) {
|
|||||||
entityName: entityName,
|
entityName: entityName,
|
||||||
entityId: entityId,
|
entityId: entityId,
|
||||||
utcSyncDate: dateUtils.utcNowDateTime(),
|
utcSyncDate: dateUtils.utcNowDateTime(),
|
||||||
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()
|
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(),
|
||||||
|
isSynced: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
sync.id = await sql.replace("sync", sync);
|
sync.id = await sql.replace("sync", sync);
|
||||||
|
@ -4,11 +4,6 @@ const syncTableService = require('./sync_table');
|
|||||||
const eventService = require('./events');
|
const eventService = require('./events');
|
||||||
|
|
||||||
async function updateEntity(sync, entity, sourceId) {
|
async function updateEntity(sync, entity, sourceId) {
|
||||||
// can be undefined for options with isSynced=false
|
|
||||||
if (!entity) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {entityName} = sync;
|
const {entityName} = sync;
|
||||||
|
|
||||||
if (entityName === 'notes') {
|
if (entityName === 'notes') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user