mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	Merge pull request #1845 from TriliumNext/renovate/sqlite-5.x
fix(deps): update dependency sqlite to v5
This commit is contained in:
		
						commit
						4ce9678b7f
					
				
							
								
								
									
										2
									
								
								.github/workflows/dev.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/dev.yml
									
									
									
									
										vendored
									
									
								
							| @ -39,7 +39,7 @@ jobs: | |||||||
| 
 | 
 | ||||||
|       - uses: nrwl/nx-set-shas@v4 |       - uses: nrwl/nx-set-shas@v4 | ||||||
|       - name: Check affected |       - name: Check affected | ||||||
|         run: pnpm nx affected -t rebuild-deps |         run: pnpm nx affected -t build rebuild-deps | ||||||
| 
 | 
 | ||||||
|   report-electron-size: |   report-electron-size: | ||||||
|     name: Report Electron size |     name: Report Electron size | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								apps/db-compare/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								apps/db-compare/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | # Database compare tool | ||||||
|  | 
 | ||||||
|  | > [!IMPORTANT] | ||||||
|  | > The original implementation was signficantly out of date. While we have made the effort of updating dependencies and getting it to run, currently it only compares the old database structure (v214). | ||||||
|  | 
 | ||||||
|  | To build and run manually: | ||||||
|  | 
 | ||||||
|  | ```sh | ||||||
|  | nx build db-compare | ||||||
|  | node ./apps/db-compare/dist/compare.js | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | To serve development build with arguments: | ||||||
|  | 
 | ||||||
|  | ```sh | ||||||
|  | nx serve db-compare --args "apps/server/spec/db/document_v214.db" --args "apps/server/spec/db/document_v214_migrated.db" | ||||||
|  | ``` | ||||||
| @ -6,7 +6,7 @@ | |||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "colors": "1.4.0", |     "colors": "1.4.0", | ||||||
|     "diff": "5.0.0", |     "diff": "5.0.0", | ||||||
|     "sqlite": "4.0.23", |     "sqlite": "5.1.1", | ||||||
|     "sqlite3": "5.1.5" |     "sqlite3": "5.1.5" | ||||||
|   }, |   }, | ||||||
|   "nx": { |   "nx": { | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import jsDiff from "diff"; | import * as jsDiff from "diff"; | ||||||
| import * as sqlite from "sqlite"; | import * as sqlite from "sqlite"; | ||||||
| import * as sqlite3 from "sqlite3"; | import * as sqlite3 from "sqlite3"; | ||||||
| import sql from "./sql.js"; | import sql from "./sql.js"; | ||||||
| 
 | 
 | ||||||
| import "colors"; | import "colors"; | ||||||
|  | import path from "path"; | ||||||
| 
 | 
 | ||||||
| function printDiff(one: string, two: string) { | function printDiff(one: string, two: string) { | ||||||
|     const diff = jsDiff.diffChars(one, two); |     const diff = jsDiff.diffChars(one, two); | ||||||
| @ -67,11 +68,30 @@ function compareRows(table: string, rsLeft: Record<string, any>, rsRight: Record | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function main() { | async function main() { | ||||||
|     const dbLeftPath = process.argv[2]; |     const dbLeftPath = process.argv.at(-2); | ||||||
|     const dbRightPath = process.argv[3]; |     const dbRightPath = process.argv.at(-1); | ||||||
| 
 | 
 | ||||||
|     const dbLeft = await sqlite.open({filename: dbLeftPath, driver: sqlite3.Database}); |     if (process.argv.length < 4 || !dbLeftPath || !dbRightPath) { | ||||||
|     const dbRight = await sqlite.open({filename: dbRightPath, driver: sqlite3.Database}); |         console.log(`Usage: ${process.argv[0]} ${process.argv[1]} path/to/first.db path/to/second.db`); | ||||||
|  |         process.exit(1); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     let dbLeft: sqlite.Database; | ||||||
|  |     let dbRight: sqlite.Database; | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  |         dbLeft = await sqlite.open({filename: dbLeftPath, driver: sqlite3.Database}); | ||||||
|  |     } catch (e: any) { | ||||||
|  |         console.error(`Could not load first database at ${path.resolve(dbRightPath)} due to: ${e.message}`); | ||||||
|  |         process.exit(2); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  |         dbRight = await sqlite.open({filename: dbRightPath, driver: sqlite3.Database}); | ||||||
|  |     } catch (e: any) { | ||||||
|  |         console.error(`Could not load second database at ${path.resolve(dbRightPath)} due to: ${e.message}`); | ||||||
|  |         process.exit(3); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     async function compare(table: string, column: string, query: string) { |     async function compare(table: string, column: string, query: string) { | ||||||
|         const rsLeft = await sql.getIndexed(dbLeft, column, query); |         const rsLeft = await sql.getIndexed(dbLeft, column, query); | ||||||
| @ -81,7 +101,7 @@ async function main() { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await compare("branches", "branchId", |     await compare("branches", "branchId", | ||||||
|         "SELECT branchId, noteId, parentNoteId, notePosition, utcDateCreated, isDeleted, prefix FROM branches"); |         "SELECT branchId, noteId, parentNoteId, notePosition, utcDateModified, isDeleted, prefix FROM branches"); | ||||||
| 
 | 
 | ||||||
|     await compare("notes", "noteId", |     await compare("notes", "noteId", | ||||||
|         "SELECT noteId, title, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0"); |         "SELECT noteId, title, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0"); | ||||||
| @ -96,13 +116,13 @@ async function main() { | |||||||
|         "SELECT noteRevisionId, content FROM note_revision_contents"); |         "SELECT noteRevisionId, content FROM note_revision_contents"); | ||||||
| 
 | 
 | ||||||
|     await compare("options", "name", |     await compare("options", "name", | ||||||
|             `SELECT name, value, utcDateCreated FROM options WHERE isSynced = 1`); |             `SELECT name, value, utcDateModified FROM options WHERE isSynced = 1`); | ||||||
| 
 | 
 | ||||||
|     await compare("attributes", "attributeId", |     await compare("attributes", "attributeId", | ||||||
|         "SELECT attributeId, noteId, type, name, value FROM attributes"); |         "SELECT attributeId, noteId, type, name, value FROM attributes"); | ||||||
| 
 | 
 | ||||||
|     await compare("api_tokens", "apiTokenId", |     await compare("etapi_tokens", "etapiTokenId", | ||||||
|         "SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens"); |         "SELECT etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted FROM etapi_tokens"); | ||||||
| 
 | 
 | ||||||
|     await compare("entity_changes", "uniqueId", |     await compare("entity_changes", "uniqueId", | ||||||
|         "SELECT entityName || '-' || entityId AS uniqueId, hash, isErased, utcDateChanged FROM entity_changes WHERE isSynced = 1"); |         "SELECT entityName || '-' || entityId AS uniqueId, hash, isErased, utcDateChanged FROM entity_changes WHERE isSynced = 1"); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import Database, { Database as DatabaseType } from "better-sqlite3"; | import Database, { type Database as DatabaseType } from "better-sqlite3"; | ||||||
| 
 | 
 | ||||||
| let dbConnection: DatabaseType; | let dbConnection: DatabaseType; | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							| @ -293,8 +293,8 @@ importers: | |||||||
|         specifier: 5.0.0 |         specifier: 5.0.0 | ||||||
|         version: 5.0.0 |         version: 5.0.0 | ||||||
|       sqlite: |       sqlite: | ||||||
|         specifier: 4.0.23 |         specifier: 5.1.1 | ||||||
|         version: 4.0.23 |         version: 5.1.1 | ||||||
|       sqlite3: |       sqlite3: | ||||||
|         specifier: 5.1.5 |         specifier: 5.1.5 | ||||||
|         version: 5.1.5(encoding@0.1.13) |         version: 5.1.5(encoding@0.1.13) | ||||||
| @ -9421,8 +9421,8 @@ packages: | |||||||
|   sqlite3@5.1.5: |   sqlite3@5.1.5: | ||||||
|     resolution: {integrity: sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==} |     resolution: {integrity: sha512-7sP16i4wI+yKnGOO2q2ijze7EjQ9US+Vw7DYYwxfFtqNZDGgBcEw0oeDaDvUTq66uJOzVd/z6MkIg+c9erSJKg==} | ||||||
| 
 | 
 | ||||||
|   sqlite@4.0.23: |   sqlite@5.1.1: | ||||||
|     resolution: {integrity: sha512-dSdmSkrdIhUL7xP/fiEMfFuAo4dxb0afag3rK8T4Y9lYxE3g3fXT0J8H9qSFvmcKxnM0zEA8yvLbpdWQ8mom3g==} |     resolution: {integrity: sha512-oBkezXa2hnkfuJwUo44Hl9hS3er+YFtueifoajrgidvqsJRQFpc5fKoAkAor1O5ZnLoa28GBScfHXs8j0K358Q==} | ||||||
| 
 | 
 | ||||||
|   ssri@12.0.0: |   ssri@12.0.0: | ||||||
|     resolution: {integrity: sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ==} |     resolution: {integrity: sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ==} | ||||||
| @ -21484,7 +21484,7 @@ snapshots: | |||||||
|       - encoding |       - encoding | ||||||
|       - supports-color |       - supports-color | ||||||
| 
 | 
 | ||||||
|   sqlite@4.0.23: {} |   sqlite@5.1.1: {} | ||||||
| 
 | 
 | ||||||
|   ssri@12.0.0: |   ssri@12.0.0: | ||||||
|     dependencies: |     dependencies: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran