document_attachment_blob_projection Client SQLite table
Declared in packages/client-sdk/src/data/sqlite/schema/documentAttachmentSchema.ts
Description
This table tracks the attachment blobs currently available to the client for each document slot. blobId is optional because the local storage key can be known before the server blob identity has been assigned or downloaded.
Indexes:
(localId, slotId)is the primary key and keeps one projected blob per document attachment slot.
Columns
local_idtext- not null
Local document id that owns the attachment slot.
slot_idtext- not null
Stable attachment slot id within the document.
blob_idtext- nullable
Server blob id when known.
storage_keytext- not null
Local blob storage key for opening the attachment.
mime_typetext- nullable
Optional MIME type associated with the blob.
byte_lengthinteger- not null
Blob size in bytes.
content_sha256text- not null
Plaintext digest of the bytes held at
storageKey. The document content records the digest it intends for the slot; a held copy whose digest differs is a validly signed served binding the document has not (yet) recorded, and read models flag it rather than hide it.updated_attext- not null
Local timestamp for the attachment projection update.
detached_attext- nullable
Local timestamp set when the slot is unlinked from a synced document. The row outlives the unlink because it is also the durable "still needs a remote detach" marker (see
syncDetachedAttachments), so read models that answer "what references this blob" must skip detached rows instead of waiting for the detach to flush.
Keys and constraints
- Primary key
(local_id, slot_id)
Indexes
document_attachment_blob_projection_storage_key_idx(storage_key)
DDL
The statements the client runs to create this table and its indexes.
CREATE TABLE IF NOT EXISTS "document_attachment_blob_projection" (
"local_id" TEXT NOT NULL,
"slot_id" TEXT NOT NULL,
"blob_id" TEXT,
"storage_key" TEXT NOT NULL,
"mime_type" TEXT,
"byte_length" INTEGER NOT NULL,
"content_sha256" TEXT NOT NULL,
"updated_at" TEXT NOT NULL,
"detached_at" TEXT,
PRIMARY KEY ("local_id", "slot_id")
);
CREATE INDEX IF NOT EXISTS "document_attachment_blob_projection_storage_key_idx" ON "document_attachment_blob_projection" ("storage_key");