Tearleads

containers Client SQLite table

Materialized local container tree.

Declared in packages/client-sdk/src/data/sqlite/schema/containerSchema.ts

Description

Container rows describe the tree and its encrypted metadata document; metadata rows live in documents. Lists show a container's server timestamps once it has synced, and its local timestamps before. (parentId) where parentId is not null serves child-folder listings.

Columns

  • idtext
    • primary key
    • nullable

    Container id; the primary key for structural lookups.

  • organization_idtext
    • not null

    Organization that owns the container.

  • parent_idtext
    • nullable

    Parent container id; null for a top-level root.

  • metadata_document_idtext
    • nullable

    Server id of the container's encrypted metadata document, whose record is the documents row with appKind container-metadata and the container id as localId. Null until known, such as for a create still waiting to sync, and cleared by a remote reset.

  • system_slottext
    • nullable

    Opaque app-owned slot naming a system folder, such as an organization's Trash: sys_v1_ and a base64url SHA-256 digest. Null for ordinary folders.

  • display_nametext
    • nullable

    Name decrypted from the metadata document. Null falls back to / for a root and Untitled otherwise when the row is read.

  • icontext
    • nullable

    Icon decrypted from the metadata document; null when none is set.

  • effective_access_leveltext
    • not null
    • default 'read'

    This user's access to the container as the server lists it: read, write, or admin. Defaults to read, and readers treat an unknown value as read; a container created on this device is admin.

  • root_lane_memberinteger
    • not null
    • default 0

    Whether the container is listed by the root lane: always true for a top-level root, and true for a nested container granted to the user directly. A completed root-lane membership sweep sets and clears it.

  • local_created_attext
    • not null

    ISO-8601 creation time recorded when the row is first inserted; later saves keep it.

  • local_updated_attext
    • not null

    ISO-8601 time of the last local change. Hydration moves it to the server's updatedAt unless a pending local metadata or structural change is newer.

  • server_created_attext
    • nullable

    ISO-8601 server creation time; null until the container has synced, and cleared by a remote reset.

  • server_updated_attext
    • nullable

    ISO-8601 server update time; null until the container has synced, and cleared by a remote reset or when the container is re-homed to another organization or metadata document.

Indexes

  • containers_parent_idx(parent_id)
    • partial: where "parent_id" IS NOT NULL
  • containers_metadata_document_idx(metadata_document_id)
    • partial: where "metadata_document_id" IS NOT NULL

DDL

The statements the client runs to create this table and its indexes.

CREATE TABLE IF NOT EXISTS "containers" (
  "id" TEXT PRIMARY KEY,
  "organization_id" TEXT NOT NULL,
  "parent_id" TEXT,
  "metadata_document_id" TEXT,
  "system_slot" TEXT,
  "display_name" TEXT,
  "icon" TEXT,
  "effective_access_level" TEXT NOT NULL DEFAULT 'read',
  "root_lane_member" INTEGER NOT NULL DEFAULT 0,
  "local_created_at" TEXT NOT NULL,
  "local_updated_at" TEXT NOT NULL,
  "server_created_at" TEXT,
  "server_updated_at" TEXT
);

CREATE INDEX IF NOT EXISTS "containers_parent_idx" ON "containers" ("parent_id") WHERE "parent_id" IS NOT NULL;

CREATE INDEX IF NOT EXISTS "containers_metadata_document_idx" ON "containers" ("metadata_document_id") WHERE "metadata_document_id" IS NOT NULL;