mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +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 = '') {
 | 
			
		||||
    try {
 | 
			
		||||
        cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey);
 | 
			
		||||
        const repository = require("./repository.js");
 | 
			
		||||
 | 
			
		||||
        sql.transactional(() => {
 | 
			
		||||
            const entityIds = sql.getColumn(`SELECT ${entityPrimaryKey} FROM ${entityName}`
 | 
			
		||||
                + (condition ? ` WHERE ${condition}` : ''));
 | 
			
		||||
 | 
			
		||||
@ -93,18 +95,22 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
 | 
			
		||||
                if (existingRows === 0) {
 | 
			
		||||
                    createdCount++;
 | 
			
		||||
 | 
			
		||||
                sql.insert("entity_changes", {
 | 
			
		||||
                    entityName: entityName,
 | 
			
		||||
                    entityId: entityId,
 | 
			
		||||
                    sourceId: "SYNC_FILL",
 | 
			
		||||
                    isSynced: 1
 | 
			
		||||
                });
 | 
			
		||||
                    const entity = repository.getEntity(`SELECT * FROM ${entityName} WHERE ${entityPrimaryKey} = ?`, [entityId]);
 | 
			
		||||
 | 
			
		||||
                    addEntityChange({
 | 
			
		||||
                        entityName,
 | 
			
		||||
                        entityId,
 | 
			
		||||
                        hash: entity.generateHash(),
 | 
			
		||||
                        isErased: false,
 | 
			
		||||
                        utcDateChanged: entity.getUtcDateChanged()
 | 
			
		||||
                    }, null);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (createdCount > 0) {
 | 
			
		||||
                log.info(`Created ${createdCount} missing entity changes for ${entityName}.`);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        // this is to fix migration from 0.30 to 0.32, can be removed later
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user