feat(db-compare): adapt to v214

This commit is contained in:
Elian Doran 2025-05-03 11:24:19 +03:00
parent b56ae01990
commit 886dd60dd0
No known key found for this signature in database
2 changed files with 22 additions and 5 deletions

17
apps/db-compare/README.md Normal file
View 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"
```

View File

@ -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");