Skip to content

Commit 1e6c8bd

Browse files
committed
fix: supply _rev for adding attachments
1 parent 6de4202 commit 1e6c8bd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/db/src/util/migrator/StaticToCouchDBMigrator.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ export class StaticToCouchDBMigrator {
425425
const cleanDoc = { ...doc };
426426
// Remove _rev if present (CouchDB will assign new revision)
427427
delete cleanDoc._rev;
428+
// Remove _attachments - these are uploaded separately in Phase 5
429+
delete cleanDoc._attachments;
428430

429431
return cleanDoc;
430432
});
@@ -575,10 +577,14 @@ export class StaticToCouchDBMigrator {
575577
}
576578
}
577579

580+
// Get current document revision (needed for putAttachment)
581+
const doc = await db.get(docId);
582+
578583
// Upload to CouchDB
579584
await db.putAttachment(
580585
docId,
581586
attachmentName,
587+
doc._rev,
582588
attachmentData as any, // PouchDB accepts both ArrayBuffer and Buffer
583589
attachmentMeta.content_type
584590
);

0 commit comments

Comments
 (0)