Skip to content
Deedboxlatest

Schema tables

This page describes the tables in the Deedbox schema. Deedbox owns only these tables; your read models stay in your own tables.

Table Key Holds
streams (tenant_id, stream_id) One row per stream: stream_type, version, stored state, state_version, state_at (the version the state reflects), deleted_at, and archived_to, the highest version in events_archive.
events global_position Every event that is not archived: event_id, tenant_id, stream_id, version, stream_type, event_type, event_version, payload, metadata, occurred_at. Unique on event_id and on (tenant_id, stream_id, version).
events_archive global_position The events of archived streams, with the columns and unique constraints of events. See table growth.
position one row The global position counter.
event_types (stream_type, event_type, event_version) Every event type ever stored; the start-up check reads it.
checkpoints name One row per projection and subscription: position, mode, status, error, handles, the event types it handles, and archive_until, set by a rebuild that includes archived events. For a stall, error holds the exception type and stack frames, never the message.
instances instance_id One row per live app instance: what it runs, what it can append, handles, the events its version of each projection and subscription handles, and formats, the newest storage format it reads. Each instance refreshes its row every 10 seconds and deletes it when it stops. A cut-over deletes the row of an instance that is not live.
jobs id Rebuilds, skips, erasures, snapshot rebuilds, archives and destroyed pseudonym periods; the audit trail. A failed job holds the exception type and stack frames, never the message.
master_keys (tenant_id, key_version) Wrapped tenant keys; shredded tenants leave tombstone rows.
subject_keys (tenant_id, subject_id) Wrapped subject keys. Erasure deletes a row.
subject_streams (tenant_id, subject_id, stream_id) Which streams hold which subject’s data. Indexed on (tenant_id, stream_id) too.
pseudonym_keys (tenant_id, period_id) One pseudonym secret per tenant and period, wrapped by the master key, and the prefix the period uses. A destroyed period leaves a tombstone row with destroyed_at.
schema_version version Applied migrations.

On Postgres, JSON columns are jsonb. On SQL Server, they are nvarchar(max), or json with native json, and key columns use the Latin1_General_100_BIN2 collation, so IDs compare case-sensitively on both databases.

Migrations are numbered, idempotent and forward-only. See apply the schema.

Migration 6, in 0.5.0, adds the instances.formats column, and indexes on subject_streams (tenant_id, stream_id) and on queued jobs. It also removes exception messages from existing stall and job rows.

Migration 7, in 0.6.0, adds the instances.handles column.

Migration 8, in 0.8.0, adds the events_archive table, and the streams.archived_to and checkpoints.archive_until columns.