attachment_bindings API Postgres table
Materialized attachment bindings between documents, slots, and blobs.
Declared in packages/api-shared/src/schema/blobs.ts
Description
Attachment bindings are written from verified attachment access events. A binding attaches a blob to one logical document slot; replacing a slot points at the previous binding, and detaching marks the active binding with detachedAt. The partial unique index enforces one active binding per document slot.
Indexes:
documentIdsupports document attachment listing.blobIdsupports resolving documents that currently expose a blob.(documentId, slotId) where detachedAt is nullis unique so one document slot has at most one active binding.
Columns
iduuid- primary key
- not null
- default gen_random_uuid()
Stable attachment binding id.
document_iduuid- not null
Document that owns the attachment slot.
slot_idtext- not null
Logical attachment slot within the document.
blob_iduuid- not null
Blob attached to the slot.
previous_binding_iduuid- nullable
Previous binding in the slot chain for replacement flows, or
nullfor the first binding.attachment_event_hashtext- nullable
Access event hash that created this binding.
document_manifest_hashtext- nullable
Document link-set manifest hash verified for the binding.
bind_document_versiontext- not null
- default '[]'
The document version the bind checked its slot against, as a JSON array of
{ peer_id, counter }rows. It can hold the uploader's unsent ops, so a detach waits until each of its ops is committed: until then, the slot's content may still be on its way.[](no ops) for bindings that predate it.detached_attimestamp- nullable
Timestamp when this binding was detached, or
nullwhile it is active.created_attimestamp- not null
- default now()
Server-side insertion timestamp.
Indexes
attachment_bindings_document_idx(document_id)attachment_bindings_blob_idx(blob_id)attachment_bindings_document_slot_active_idx(document_id, slot_id)- unique
- partial:
where "detached_at" is null