mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix filling entity changes from Options' Advanced tab, closes #1898
This commit is contained in:
parent
03f3e46f8b
commit
b1131844d6
@ -80,7 +80,9 @@ function cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey) {
|
|||||||
function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
||||||
try {
|
try {
|
||||||
cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey);
|
cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey);
|
||||||
|
const repository = require("./repository.js");
|
||||||
|
|
||||||
|
sql.transactional(() => {
|
||||||
const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName}`
|
const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName}`
|
||||||
+ (condition ? ` WHERE ${condition}` : ''));
|
+ (condition ? ` WHERE ${condition}` : ''));
|
||||||
|
|
||||||
@ -93,18 +95,22 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
|||||||
if (existingRows === 0) {
|
if (existingRows === 0) {
|
||||||
createdCount++;
|
createdCount++;
|
||||||
|
|
||||||
sql.insert("entity_changes", {
|
const entity = repository.getEntity(`SELECT * FROM ${entityName} WHERE ${entityPrimaryKey} = ?`, [entityId]);
|
||||||
entityName: entityName,
|
|
||||||
entityId: entityId,
|
addEntityChange({
|
||||||
sourceId: "SYNC_FILL",
|
entityName,
|
||||||
isSynced: 1
|
entityId,
|
||||||
});
|
hash: entity.generateHash(),
|
||||||
|
isErased: false,
|
||||||
|
utcDateChanged: entity.getUtcDateChanged()
|
||||||
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createdCount > 0) {
|
if (createdCount > 0) {
|
||||||
log.info(`Created ${createdCount} missing entity changes for ${entityName}.`);
|
log.info(`Created ${createdCount} missing entity changes for ${entityName}.`);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// this is to fix migration from 0.30 to 0.32, can be removed later
|
// this is to fix migration from 0.30 to 0.32, can be removed later
|
||||||
|
Loading…
x
Reference in New Issue
Block a user