From 3853ce7f1a8980931afd2267447192f1885691cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 25 Oct 2026 03:02:56 +0100 Subject: [PATCH] fix(backup): order the source aliases a deleted document's keys are read from The backup export is totally ordered so two exports of the same account are byte-identical; the alias relation the import-key ledger reads was the one nested read without an order. --- src/lib/documents/tombstones.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/documents/tombstones.ts b/src/lib/documents/tombstones.ts index 7ca5e337d..f6ee18c9d 100644 --- a/src/lib/documents/tombstones.ts +++ b/src/lib/documents/tombstones.ts @@ -45,6 +45,8 @@ export const SOURCE_KEY_SELECT = { sourceId: true, sourceInstance: true, sourceAliases: { + // The backup reads through this select, and its export is totally ordered. + orderBy: [{ createdAt: "asc" }, { id: "asc" }], select: { sourceSystem: true, sourceId: true, sourceInstance: true }, }, } as const;