mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	DB migration fixes
This commit is contained in:
		| @@ -5,10 +5,12 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( | ||||
|                                                 `hash`	TEXT NOT NULL, | ||||
|                                                 `isErased` INT NOT NULL, | ||||
|                                                 `sourceId` TEXT NOT NULL, | ||||
|                                                 `isSynced` INTEGER NOT NULL); | ||||
|                                                 `isSynced` INTEGER NOT NULL, | ||||
|                                                 `utcDateChanged` TEXT NOT NULL | ||||
|                                                 ); | ||||
|  | ||||
| INSERT INTO mig_entity_changes (entityName, entityId, hash, sourceId, isSynced, isErased) | ||||
|     SELECT entityName, entityId, '', sourceId, isSynced, isErased FROM entity_changes; | ||||
| INSERT INTO mig_entity_changes (entityName, entityId, hash, sourceId, isSynced, isErased, utcDateChanged) | ||||
|     SELECT entityName, entityId, '', sourceId, isSynced, isErased, utcDateChanged FROM entity_changes; | ||||
|  | ||||
| UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM api_tokens WHERE apiTokenId = entityId), '') WHERE entityName = 'api_tokens'; | ||||
| UPDATE mig_entity_changes SET hash = COALESCE((SELECT hash FROM attributes WHERE attributeId = entityId), '') WHERE entityName = 'attributes'; | ||||
|   | ||||
| @@ -465,7 +465,13 @@ class ConsistencyChecks { | ||||
|                 if (this.autoFix) { | ||||
|                     const entity = repository.getEntity(`SELECT * FROM ${entityName} WHERE ${key} = ?`, [entityId]); | ||||
|  | ||||
|                     entityChangesService.addEntityChange(entityName, entityId, entity.generateHash()); | ||||
|                     entityChangesService.addEntityChange({ | ||||
|                         entityName, | ||||
|                         entityId, | ||||
|                         hash: entity.generateHash(), | ||||
|                         isErased: false, | ||||
|                         utcDateChanged: entity.getUtcDateChanged() | ||||
|                     }, null); | ||||
|  | ||||
|                     logFix(`Created missing entity change for entityName=${entityName}, entityId=${entityId}`); | ||||
|                 } else { | ||||
|   | ||||
| @@ -62,7 +62,7 @@ async function migrate() { | ||||
|                 } | ||||
|  | ||||
|                 // not using repository because of changed utcDateModified column in migration 129 | ||||
|                 sql.execute(`UPDATE options SET value = ? WHERE name = ?`, [mig.dbVersion, "dbVersion"]); | ||||
|                 sql.execute(`UPDATE options SET value = ? WHERE name = ?`, [mig.dbVersion.toString(), "dbVersion"]); | ||||
|             }); | ||||
|  | ||||
|             log.info("Migration to version " + mig.dbVersion + " has been successful."); | ||||
|   | ||||
| @@ -58,7 +58,6 @@ function initNotSyncedOptions(initialized, startNotePath = 'root', opts = {}) { | ||||
| const defaultOptions = [ | ||||
|     { name: 'noteRevisionSnapshotTimeInterval', value: '600', isSynced: true }, | ||||
|     { name: 'protectedSessionTimeout', value: '600', isSynced: true }, | ||||
|     { name: 'hoistedNoteId', value: 'root', isSynced: false }, | ||||
|     { name: 'zoomFactor', value: '1.0', isSynced: false }, | ||||
|     { name: 'mainFontSize', value: '100', isSynced: false }, | ||||
|     { name: 'treeFontSize', value: '100', isSynced: false }, | ||||
|   | ||||
| @@ -210,6 +210,8 @@ function wrap(query, func) { | ||||
|  | ||||
|             return null | ||||
|         } | ||||
|  | ||||
|         throw e; | ||||
|     } | ||||
|  | ||||
|     const milliseconds = Date.now() - startTimestamp; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user