document_pending_attachments Client SQLite table
Pending attachment uploads for local document changes.
Declared in packages/client-sdk/src/data/sqlite/schema/documentAttachmentSchema.ts
Description
These rows describe attachment blobs referenced by local document mutations that have not yet been folded into the synced attachment/blob projection. Once the attachment is accepted or discarded, the pending row is removed.
Indexes:
(localId, slotId)is the primary key and keeps one pending 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.
nametext- not null
User-facing attachment filename.
mime_typetext- nullable
Optional MIME type supplied for the blob.
storage_keytext- not null
Local blob storage key for upload/readback.
byte_lengthinteger- not null
Blob size in bytes.
content_sha256text- not null
Hex SHA-256 of the plaintext bytes at
storageKey. An upload whose source no longer hashes to it is skipped.created_attext- not null
Queue insertion timestamp used for ordered display.
requeuedinteger- not null
- default 0
Held bytes staged again for a slot that was bound before, so the upload lane lists the slot's binding before it binds.
upload_blob_idtext- nullable
Random blob id this device chooses for the upload. It is saved with the content key, IV seed, key epoch, and plaintext digest before the first upload attempt; the five are null until then.
upload_content_keytext- nullable
Base64 of the random 32-byte key that encrypts the blob. Reusing it with the same IV seed makes every retried chunk byte-identical.
upload_ivtext- nullable
Base64 IV seed from which the envelope and chunk IVs are derived.
upload_content_key_epochinteger- nullable
Epoch of the upload's content key; 1 for a new upload identity.
upload_part_sizeinteger- nullable
Part size in bytes (the encryption chunk size) and server id of the multipart stage, saved before any part is sent so an interrupted upload resumes the same stage. Null, together, until a stage is resolved.
upload_plaintext_sha256text- nullable
Hex SHA-256 of the plaintext the upload identity was made for. Bytes with another digest get a fresh identity.
upload_stage_idtext- nullable
Part size in bytes (the encryption chunk size) and server id of the multipart stage, saved before any part is sent so an interrupted upload resumes the same stage. Null, together, until a stage is resolved.
Keys and constraints
- Primary key
(local_id, slot_id)
Indexes
document_pending_attachments_storage_key_idx(storage_key)
DDL
The statements the client runs to create this table and its indexes.
CREATE TABLE IF NOT EXISTS "document_pending_attachments" (
"local_id" TEXT NOT NULL,
"slot_id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"mime_type" TEXT,
"storage_key" TEXT NOT NULL,
"byte_length" INTEGER NOT NULL,
"content_sha256" TEXT NOT NULL,
"created_at" TEXT NOT NULL,
"requeued" INTEGER NOT NULL DEFAULT 0,
"upload_blob_id" TEXT,
"upload_content_key" TEXT,
"upload_iv" TEXT,
"upload_content_key_epoch" INTEGER,
"upload_part_size" INTEGER,
"upload_plaintext_sha256" TEXT,
"upload_stage_id" TEXT,
PRIMARY KEY ("local_id", "slot_id")
);
CREATE INDEX IF NOT EXISTS "document_pending_attachments_storage_key_idx" ON "document_pending_attachments" ("storage_key");