From 886dd60dd039068d7c25bfc7e33793f44adbe87b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 3 May 2025 11:24:19 +0300 Subject: [PATCH] feat(db-compare): adapt to v214 --- apps/db-compare/README.md | 17 +++++++++++++++++ apps/db-compare/src/compare.ts | 10 +++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 apps/db-compare/README.md diff --git a/apps/db-compare/README.md b/apps/db-compare/README.md new file mode 100644 index 000000000..4cc13218a --- /dev/null +++ b/apps/db-compare/README.md @@ -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" +``` \ No newline at end of file diff --git a/apps/db-compare/src/compare.ts b/apps/db-compare/src/compare.ts index c1e1b26cc..64410cafe 100644 --- a/apps/db-compare/src/compare.ts +++ b/apps/db-compare/src/compare.ts @@ -1,6 +1,6 @@ "use strict"; -import jsDiff from "diff"; +import * as jsDiff from "diff"; import * as sqlite from "sqlite"; import * as sqlite3 from "sqlite3"; import sql from "./sql.js"; @@ -101,7 +101,7 @@ async function main() { } 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", "SELECT noteId, title, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0"); @@ -116,13 +116,13 @@ async function main() { "SELECT noteRevisionId, content FROM note_revision_contents"); 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", "SELECT attributeId, noteId, type, name, value FROM attributes"); - await compare("api_tokens", "apiTokenId", - "SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens"); + await compare("etapi_tokens", "etapiTokenId", + "SELECT etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted FROM etapi_tokens"); await compare("entity_changes", "uniqueId", "SELECT entityName || '-' || entityId AS uniqueId, hash, isErased, utcDateChanged FROM entity_changes WHERE isSynced = 1");