mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-26 17:41:34 +08:00 
			
		
		
		
	make migration more robust for cases where attribute definitions don't contain valid values, closes #1207
This commit is contained in:
		
							parent
							
								
									6aa61ca306
								
							
						
					
					
						commit
						b7b13c1d8b
					
				| @ -2,7 +2,19 @@ const sql = require('../../src/services/sql'); | ||||
| 
 | ||||
| module.exports = () => { | ||||
|     for (const attr of sql.getRows("SELECT * FROM attributes WHERE name LIKE 'label:%'")) { | ||||
|         const obj = JSON.parse(attr.value); | ||||
|         let obj; | ||||
| 
 | ||||
|         try { | ||||
|             obj = JSON.parse(attr.value); | ||||
|         } | ||||
|         catch (e) { | ||||
|             console.log(`Parsing attribute definition "${attr.value}" of ${attr.attributeId} failed with error "${e.message}", setting to default value.`); | ||||
| 
 | ||||
|             sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', | ||||
|                 ["multi,text", attr.attributeId]); | ||||
| 
 | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         const tokens = []; | ||||
| 
 | ||||
| @ -30,7 +42,19 @@ module.exports = () => { | ||||
|     } | ||||
| 
 | ||||
|     for (const attr of sql.getRows("SELECT * FROM attributes WHERE name LIKE 'relation:%'")) { | ||||
|         const obj = JSON.parse(attr.value); | ||||
|         let obj; | ||||
| 
 | ||||
|         try { | ||||
|             obj = JSON.parse(attr.value); | ||||
|         } | ||||
|         catch (e) { | ||||
|             console.log(`Parsing attribute definition "${attr.value}" of ${attr.attributeId} failed with error "${e.message}", setting to default value.`); | ||||
| 
 | ||||
|             sql.execute('UPDATE attributes SET value = ? WHERE attributeId = ?', | ||||
|                 ["multi", attr.attributeId]); | ||||
| 
 | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         const tokens = []; | ||||
| 
 | ||||
|  | ||||
| @ -41,7 +41,7 @@ | ||||
|     "electron-window-state": "5.0.3", | ||||
|     "express": "4.17.1", | ||||
|     "express-session": "1.17.1", | ||||
|     "file-type": "14.7.1", | ||||
|     "file-type": "15.0.0", | ||||
|     "fs-extra": "9.0.1", | ||||
|     "helmet": "4.1.0", | ||||
|     "html": "1.0.0", | ||||
| @ -62,7 +62,7 @@ | ||||
|     "request": "^2.88.2", | ||||
|     "rimraf": "3.0.2", | ||||
|     "sanitize-filename": "1.6.3", | ||||
|     "sanitize-html": "1.27.3", | ||||
|     "sanitize-html": "1.27.4", | ||||
|     "sax": "1.2.4", | ||||
|     "semver": "7.3.2", | ||||
|     "serve-favicon": "2.5.0", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam