fix(core): re-point source records when a per-user move merges entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas Winther
2026-10-30 20:43:08 +01:00
co-authored by Claude Opus 5.5
parent 6efb97eb51
commit 0604c323c3
+10
View File
@@ -579,6 +579,16 @@ async function moveEntry(
await moveEngagements(k, userId, src.id, dst.id, actor);
await writeEntry(k, src, {}, actor, { extra: { deleted_at: nowIso() } });
}
if (result.id !== src.id) {
// The moved entry merged into another one: source records that mapped to it keep syncing into the
// survivor. Engagements keep their ids when re-parented, so their mappings stay valid.
await k
.updateTable("source_records")
.set({ target_id: result.id })
.where("target_entity", "=", "entry")
.where("target_id", "=", src.id)
.execute();
}
if (opts.undo) return result;
await repointCopiesAndListItems(k, userId, src.workId, target.id, actor);