mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 00:02:28 +08:00
updated for 0.48 + tweaks
This commit is contained in:
parent
57db2adf2d
commit
22d59127f9
22
compare.js
22
compare.js
@ -1,13 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
require('colors');
|
require('colors');
|
||||||
const jsdiff = require('diff');
|
const jsDiff = require('diff');
|
||||||
const sqlite = require('sqlite');
|
const sqlite = require('sqlite');
|
||||||
const sqlite3 = require('sqlite3');
|
const sqlite3 = require('sqlite3');
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
|
|
||||||
function printDiff(one, two) {
|
function printDiff(one, two) {
|
||||||
const diff = jsdiff.diffChars(one, two);
|
const diff = jsDiff.diffChars(one, two);
|
||||||
|
|
||||||
diff.forEach(function(part){
|
diff.forEach(function(part){
|
||||||
// green for additions, red for deletions
|
// green for additions, red for deletions
|
||||||
@ -16,6 +16,8 @@ function printDiff(one, two) {
|
|||||||
part.removed ? 'red' : 'grey';
|
part.removed ? 'red' : 'grey';
|
||||||
process.stderr.write(part.value[color]);
|
process.stderr.write(part.value[color]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkMissing(table, name, ids1, ids2) {
|
function checkMissing(table, name, ids1, ids2) {
|
||||||
@ -38,6 +40,8 @@ function compareRows(table, rsLeft, rsRight, column) {
|
|||||||
const leftIds = Object.keys(rsLeft);
|
const leftIds = Object.keys(rsLeft);
|
||||||
const rightIds = Object.keys(rsRight);
|
const rightIds = Object.keys(rsRight);
|
||||||
|
|
||||||
|
console.log("");
|
||||||
|
console.log("--------------------------------------------------------");
|
||||||
console.log(`${table} - ${leftIds.length}/${rightIds.length}`);
|
console.log(`${table} - ${leftIds.length}/${rightIds.length}`);
|
||||||
|
|
||||||
checkMissing(table, "right", leftIds, rightIds);
|
checkMissing(table, "right", leftIds, rightIds);
|
||||||
@ -76,25 +80,25 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await compare("branches", "branchId",
|
await compare("branches", "branchId",
|
||||||
"SELECT branchId, noteId, parentNoteId, notePosition, utcDateCreated, utcDateModified, isDeleted, prefix FROM branches");
|
"SELECT branchId, noteId, parentNoteId, notePosition, utcDateCreated, isDeleted, prefix FROM branches");
|
||||||
|
|
||||||
await compare("notes", "noteId",
|
await compare("notes", "noteId",
|
||||||
"SELECT noteId, title, dateModified, utcDateModified, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0");
|
"SELECT noteId, title, dateCreated, utcDateCreated, isProtected, isDeleted FROM notes WHERE isDeleted = 0");
|
||||||
|
|
||||||
await compare("note_contents", "noteId",
|
await compare("note_contents", "noteId",
|
||||||
"SELECT note_contents.noteId, note_contents.content, note_contents.utcDateModified FROM note_contents JOIN notes USING(noteId) WHERE isDeleted = 0");
|
"SELECT note_contents.noteId, note_contents.content FROM note_contents JOIN notes USING(noteId) WHERE isDeleted = 0");
|
||||||
|
|
||||||
await compare("note_revisions", "noteRevisionId",
|
await compare("note_revisions", "noteRevisionId",
|
||||||
"SELECT noteRevisionId, noteId, title, utcDateModified, dateCreated, dateLastEdited, utcDateCreated, utcDateLastEdited, isProtected FROM note_revisions");
|
"SELECT noteRevisionId, noteId, title, dateCreated, dateLastEdited, utcDateCreated, utcDateLastEdited, isProtected FROM note_revisions");
|
||||||
|
|
||||||
await compare("note_revision_contents", "noteRevisionId",
|
await compare("note_revision_contents", "noteRevisionId",
|
||||||
"SELECT note_revision_contents.noteRevisionId, note_revision_contents.content, note_revision_contents.utcDateModified FROM note_revision_contents JOIN note_revisions USING(noteRevisionId)");
|
"SELECT noteRevisionId, content FROM note_revision_contents");
|
||||||
|
|
||||||
await compare("options", "name",
|
await compare("options", "name",
|
||||||
`SELECT name, value, utcDateCreated, utcDateModified FROM options WHERE isSynced = 1`);
|
`SELECT name, value, utcDateCreated FROM options WHERE isSynced = 1`);
|
||||||
|
|
||||||
await compare("attributes", "attributeId",
|
await compare("attributes", "attributeId",
|
||||||
"SELECT attributeId, noteId, type, name, value, utcDateModified FROM attributes");
|
"SELECT attributeId, noteId, type, name, value FROM attributes");
|
||||||
|
|
||||||
await compare("api_tokens", "apiTokenId",
|
await compare("api_tokens", "apiTokenId",
|
||||||
"SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens");
|
"SELECT apiTokenId, token, utcDateCreated, isDeleted FROM api_tokens");
|
||||||
|
1183
package-lock.json
generated
1183
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,9 +3,9 @@
|
|||||||
"description": "Trilium database compare tool",
|
"description": "Trilium database compare tool",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"colors": "^1.4.0",
|
"colors": "1.4.0",
|
||||||
"diff": "^5.0.0",
|
"diff": "5.0.0",
|
||||||
"sqlite": "^4.0.19",
|
"sqlite": "4.0.23",
|
||||||
"sqlite3": "^5.0.1"
|
"sqlite3": "5.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user