Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 886dd60

Browse files
committed
feat(db-compare): adapt to v214
1 parent b56ae01 commit 886dd60

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

apps/db-compare/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Database compare tool
2+
3+
> [!IMPORTANT]
4+
> 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).
5+
6+
To build and run manually:
7+
8+
```sh
9+
nx build db-compare
10+
node ./apps/db-compare/dist/compare.js
11+
```
12+
13+
To serve development build with arguments:
14+
15+
```sh
16+
nx serve db-compare --args "apps/server/spec/db/document_v214.db" --args "apps/server/spec/db/document_v214_migrated.db"
17+
```

apps/db-compare/src/compare.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
import jsDiff from "diff";
3+
import * as jsDiff from "diff";
44
import * as sqlite from "sqlite";
55
import * as sqlite3 from "sqlite3";
66
import sql from "./sql.js";
@@ -101,7 +101,7 @@ async function main() {
101101
}
102102

103103
await compare("branches", "branchId",
104-
"SELECT branchId, noteId, parentNoteId, notePosition, utcDateCreated, isDeleted, prefix FROM branches");
104+
"SELECT branchId, noteId, parentNoteId, notePosition, utcDateModified, isDeleted, prefix FROM branches");
105105

106106
await compare("notes", "noteId",
107107
"SELECT noteId, title, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0");
@@ -116,13 +116,13 @@ async function main() {
116116
"SELECT noteRevisionId, content FROM note_revision_contents");
117117

118118
await compare("options", "name",
119-
`SELECT name, value, utcDateCreated FROM options WHERE isSynced = 1`);
119+
`SELECT name, value, utcDateModified FROM options WHERE isSynced = 1`);
120120

121121
await compare("attributes", "attributeId",
122122
"SELECT attributeId, noteId, type, name, value FROM attributes");
123123

124-
await compare("api_tokens", "apiTokenId",
125-
"SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens");
124+
await compare("etapi_tokens", "etapiTokenId",
125+
"SELECT etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted FROM etapi_tokens");
126126

127127
await compare("entity_changes", "uniqueId",
128128
"SELECT entityName || '-' || entityId AS uniqueId, hash, isErased, utcDateChanged FROM entity_changes WHERE isSynced = 1");

0 commit comments

Comments
 (0)