mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 20:06:08 +01:00
fix incorrect import of relations from tar
This commit is contained in:
@@ -64,12 +64,14 @@ async function fillSyncRows(entityName, entityKey, condition = '') {
|
||||
const entityIds = await sql.getColumn(`SELECT ${entityKey} FROM ${entityName}`
|
||||
+ (condition ? ` WHERE ${condition}` : ''));
|
||||
|
||||
let createdCount = 0;
|
||||
|
||||
for (const entityId of entityIds) {
|
||||
const existingRows = await sql.getValue("SELECT COUNT(id) FROM sync WHERE entityName = ? AND entityId = ?", [entityName, entityId]);
|
||||
|
||||
// we don't want to replace existing entities (which would effectively cause full resync)
|
||||
if (existingRows === 0) {
|
||||
log.info(`Creating missing sync record for ${entityName} ${entityId}`);
|
||||
createdCount++;
|
||||
|
||||
await sql.insert("sync", {
|
||||
entityName: entityName,
|
||||
@@ -79,6 +81,10 @@ async function fillSyncRows(entityName, entityKey, condition = '') {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (createdCount > 0) {
|
||||
log.info(`Created ${createdCount} missing sync records for ${entityName}.`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// this is to fix migration from 0.30 to 0.32, can be removed later
|
||||
|
||||
Reference in New Issue
Block a user