content migration fixes

This commit is contained in:
zadam
2019-03-27 21:04:25 +01:00
parent 29c60581a6
commit 07e9013152
33 changed files with 358 additions and 919 deletions

View File

@@ -357,13 +357,6 @@ async function findLogicIssues() {
logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
});
await findIssues(`
SELECT noteId
FROM notes
JOIN note_contents USING(noteId)
WHERE notes.isDeleted = 0 AND notes.isProtected != note_contents.isProtected`,
({noteId}) => `Note ${noteId} has inconsistent isProtected in notes and note_contents tables`);
}
async function runSyncRowChecks(entityName, key) {

View File

@@ -58,7 +58,7 @@ async function sync() {
};
}
else {
log.info("sync failed: " + e.message);
log.info("sync failed: " + e.message + e.stack);
return {
success: false,
@@ -262,6 +262,12 @@ async function getEntityRow(entityName, entityId) {
const entity = await sql.getRow(`SELECT * FROM ${entityName} WHERE ${primaryKey} = ?`, [entityId]);
if (!entity) {
console.log(entityName, entityId);
console.log(`SELECT * FROM ${entityName} WHERE ${primaryKey} = '${entityId}'`);
}
if (['note_contents', 'note_revisions'].includes(entityName) && entity.content !== null) {
if (typeof entity.content === 'string') {
entity.content = Buffer.from(entity.content, 'UTF-8');

View File

@@ -88,7 +88,7 @@ async function fillAllSyncRows() {
await sql.execute("DELETE FROM sync");
await fillSyncRows("notes", "noteId");
await fillSyncRows("note_contents", "noteContentId");
await fillSyncRows("note_contents", "noteId");
await fillSyncRows("branches", "branchId");
await fillSyncRows("note_revisions", "noteRevisionId");
await fillSyncRows("recent_notes", "branchId");