From 1f99974321e6fbd6b74eac35b8528bf62c1a2d3d Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Tue, 5 May 2026 17:12:47 -0500 Subject: [PATCH] Copy database in binary mode --- bin/copyDb.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/copyDb.ts b/bin/copyDb.ts index 2ce3c5ab8..c57ae0833 100644 --- a/bin/copyDb.ts +++ b/bin/copyDb.ts @@ -200,9 +200,18 @@ export async function copyDb(sourceDatabase: string, targetDatabasePath: string) await copyDbi(sourceDbi, targetDbi, isPrimary, transaction); } if (sourceAuditStore) { - const targetAuditStore = rootStore.openDB(AUDIT_STORE_NAME, AUDIT_STORE_OPTIONS); + // Copy audit store in binary mode to avoid encode/decode issues with symbol-keyed metadata entries + const auditBinaryOptions: any = { + keyEncoder: AUDIT_STORE_OPTIONS.keyEncoder, + encoding: 'binary', + }; + const sourceAuditBinary: any = rootStore.openDB(AUDIT_STORE_NAME, auditBinaryOptions); + sourceAuditBinary.decoder = null; + sourceAuditBinary.decoderCopies = false; + const targetAuditStore: any = targetEnv.openDB(AUDIT_STORE_NAME, auditBinaryOptions); + targetAuditStore.encoder = null; console.log('copying audit log for', sourceDatabase, 'to', targetDatabasePath); - copyDbi(sourceAuditStore, targetAuditStore, false, transaction); + await copyDbi(sourceAuditBinary, targetAuditStore, false, transaction); } async function copyDbi(sourceDbi, targetDbi, isPrimary, transaction) {