Tearleads

purged_object_reservations API Postgres table

Container and document ids an organization billing purge freed, each held for the one user who owned that personal organization.

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

Description

Ordinary billing-purge recovery derives fresh HKDF-SHA256 replacement ids per replacement organization, while canonical objects (such as the owner's personal "Me" contact) may be created again under their stable id. The purge records every id it frees in the same transaction that deletes its rows, naming the user whose default organization was purged: the only user assertReplacementReady lets replace it. Every create path refuses a reserved id to any other user as anti-squatting defense-in-depth, so nobody who learned an old id from history can take it in another organization. An owner's create under a reserved id deletes the row in its own transaction; from then on the id's head refuses other creates. A shared organization has no owner who can recover it, so its purge reserves nothing.

Rows never expire: they guard old purged ids for the lifetime of the owner's user row, are bounded by the owner's own purged folders and documents, and cascade away with the owner's user row.

Columns

  • object_kindtext
    • not null

    container or document: the id space objectId belongs to.

  • object_iduuid
    • not null

    The freed container or document id. With objectKind it is the primary key, so an id is reserved at most once.

  • owner_user_iduuid
    • not null
    • references users (id)

    The user whose personal organization was purged: the only user whose create may consume the reservation. Deleting the user deletes the row.

  • purged_organization_iduuid
    • not null

    The purged personal organization the id belonged to.

  • created_attimestamp
    • not null
    • default now()

    When the purge reserved the id.

Keys and constraints

  • Primary key(object_kind, object_id)
  • Foreign key(owner_user_id)references users (id)

    on delete cascade

Indexes

  • purged_object_reservations_owner_idx(owner_user_id)