Tearleads

blob_stages API Postgres table

Temporary encrypted blob uploads awaiting attachment mutation.

Declared in packages/api-shared/src/schema/blobs.ts

Description

Staging lets a user upload encrypted bytes and receive a stage id before the authorized attachment mutation promotes those bytes into blobs. Promotion requires the same owner user, a non-expired stage, and matching blob write header/ciphertext hash. Promoted stages are deleted.

Columns

  • iduuid
    • primary key
    • not null
    • default gen_random_uuid()

    Stage id returned to the client.

  • owner_user_iduuid
    • not null

    User who created the stage and is allowed to promote it.

  • organization_iduuid
    • not null

    Immutable organization namespace, checked at promotion.

  • storage_keytext
    • not null

    Object-store key used for the multipart upload.

  • upload_idtext
    • not null

    Object-store multipart upload id.

  • completed_attimestamp
    • nullable

    Multipart completion timestamp; null while pending.

  • sha256text
    • not null

    Expected SHA-256 digest of the completed encrypted object.

  • byte_lengthinteger
    • not null

    Expected byte length of the completed encrypted object.

  • expires_attimestamp
    • not null

    Expiration timestamp after which promotion is rejected.

  • created_attimestamp
    • not null
    • default now()

    Server-side staging timestamp.

Indexes

  • blob_stages_expires_at_idx(expires_at, id)
    • blob_stages_organization_expires_at_idx(organization_id, expires_at, id)
      • blob_stages_owner_expires_at_idx(owner_user_id, expires_at)