Data model and storage
The platform keeps all of its state in one PostgreSQL database. There is no second store for
messaging state: events, dispatch jobs, the Postgres queue backend (when used) and the push log all
live beside identity and configuration. Redis is optional and holds nothing durable (leader election,
and optionally rate limits and the push log). This page maps the schema for operators and
maintainers; the exact columns are in the migrations under internal/migrate/sql/.
Table families
Section titled “Table families”Every table name starts with a prefix that says which part of the platform owns it.
| Prefix | Family | Main tables | Size |
|---|---|---|---|
tnt_ |
Tenancy | tnt_clients, tnt_anchor_domains, tnt_email_domain_mappings (and their allowed-role and granted-client tables), tnt_client_auth_configs, tnt_cors_allowed_origins |
Small |
iam_ |
Identity and access | iam_principals (users and service accounts), iam_service_accounts, iam_roles, iam_role_permissions, iam_principal_roles, iam_client_access_grants, iam_principal_application_access, MFA (iam_user_mfa_methods, iam_user_mfa_recovery_codes, iam_mfa_email_pins, iam_mfa_trusted_devices), password reset (iam_password_reset_tokens, iam_reset_approval_requests), iam_login_attempts, iam_rate_limit_events, jwt_signing_keys (no prefix; the rotating signing keyring, private keys sealed under the application key), iam_credential_publications and iam_credential_publication_items (the work list for publishing credentials to Parameter Store) |
Small, except login attempts and rate-limit events |
oauth_ |
The OIDC provider and the bridge to organisation identity providers | oauth_clients (with redirect URIs, origins, grant types, application ids), oauth_oidc_payloads (tokens and codes), oauth_oidc_login_states, oauth_identity_providers, oauth_idp_role_mappings, oauth_identity_provider_certificates (certificates for IdP client authentication) |
Small; payloads churn and are purged |
webauthn_ |
Passkeys | webauthn_credentials |
Small |
app_ |
Applications and configuration | app_applications, app_client_configs, app_application_openapi_specs, app_docs, app_platform_configs, app_platform_config_access; for over-the-air app updates, app_update_files, app_updates, app_update_assets, app_binary_files, app_binaries and app_install_links |
Small |
msg_ |
Messaging | msg_event_types (and spec versions), msg_subscriptions (and event types, custom config), msg_connections, msg_dispatch_pools, msg_events, msg_dispatch_jobs, msg_dispatch_job_attempts, msg_dispatch_job_keys, msg_dispatch_job_descriptors (a display name per dispatch job code), msg_payloads (event and job payloads, inline or a reference to the payload store), the *_read projections, msg_scheduled_jobs, msg_scheduled_job_instances, msg_scheduled_job_instance_logs, msg_scheduled_job_ticks, msg_processes |
Events, jobs, attempts and their projections are the large tables |
aud_ |
Audit | aud_logs |
Grows with every write operation |
fng_ |
Functions | fng_functions, fng_versions, fng_aliases, fng_routes, fng_domains, fng_settings, fng_runners, fng_pool_revisions, fng_trace_contexts, fng_trace_log |
Small, except trace logs (retention-pruned) |
ing_ |
Ingestion | ing_ingestions, ing_versions, ing_sets, ing_set_applies, ing_runtimes, ing_leases, ing_state, ing_route_states, ing_job_keys, ing_failures, ing_exchange_metrics, ing_test_requests, ing_trace_windows, ing_trace_log, ing_secret_fetches |
Metrics, failures and keys grow with traffic (retention-pruned) |
portal_ |
The portal identity plane | portal_identities, portal_apps, portal_identity_apps, portal_login_flows |
Small |
field_ |
Field-worker identity | field_identities, field_devices, field_sessions, field_badges, field_enrolment_codes, field_sign_in_codes, field_nonces, field_policies, field_login_attempts, field_policy_overrides and field_policy_locks (per-application overrides of a client’s policy, and which members a client locks), field_unlock_keys and field_unlock_challenges (biometric unlock keys), field_worker_photos, and the application links |
Small; nonces and attempts purged; photos are stored in the database |
push_, fw_ |
The push gateway | push_rules, push_ticket_keys, push_app_settings, push_ingest_ids, push_dpop_proofs, push_trace_windows, push_gateway_stats; the framework push module’s fw_push_outbox, fw_push_log and fw_lock |
The push log grows with traffic and is trimmed by the gateway |
Two tables are created at runtime rather than by a migration: queue_messages, the built-in
PostgreSQL queue, created by the dispatch scheduler’s publisher when the queue type is not SQS; and
outbox_messages, created by the outbox processor when it drains the platform’s own database. Two
early tables, msg_event_projection_feed and msg_dispatch_job_projection_feed, are left from an
earlier projection design and are not used.
The messaging tables
Section titled “The messaging tables”erDiagram
MSG_EVENT_TYPES ||..o{ MSG_SUBSCRIPTION_EVENT_TYPES : "matched by pattern"
MSG_SUBSCRIPTIONS ||..|{ MSG_SUBSCRIPTION_EVENT_TYPES : "lists"
MSG_CONNECTIONS ||..o{ MSG_SUBSCRIPTIONS : "signs and pauses"
MSG_DISPATCH_POOLS ||..o{ MSG_SUBSCRIPTIONS : "paces"
MSG_EVENTS ||..o{ MSG_DISPATCH_JOBS : "fan-out raises"
MSG_SUBSCRIPTIONS ||..o{ MSG_DISPATCH_JOBS : "raised for"
MSG_DISPATCH_JOBS ||..o{ MSG_DISPATCH_JOB_ATTEMPTS : "records"
MSG_DISPATCH_JOBS ||..o| MSG_DISPATCH_JOB_KEYS : "idempotency"
MSG_EVENTS ||..|| MSG_EVENTS_READ : "projected"
MSG_DISPATCH_JOBS ||..|| MSG_DISPATCH_JOBS_READ : "projected"
Every line in the diagram is a logical reference: a column holding another row’s id. None of them is a foreign-key constraint. The partitioned tables cannot carry one usefully (their partitions are dropped), and the rest are resolved by the code that writes them.
| Table | Holds | Notes |
|---|---|---|
msg_events |
Every event accepted by ingest | Partitioned. fanned_out_at and projected_at record the stream processor’s progress. deduplication_id is unique per partition |
msg_dispatch_jobs |
One row per delivery to one target | Partitioned. status is written only by the dispatch-job lifecycle (dispatchjob/lifecycle.go). Carries the payload, the message group and position, retry state, not_before, expires_at and projected_at |
msg_dispatch_job_attempts |
One row per delivery attempt: status code, timing, error | Partitioned |
msg_dispatch_job_keys |
Idempotency keys of jobs created through the API | Not partitioned, no foreign key; kept 7 days |
msg_payloads |
One row per stored payload, pointed at by an event and its jobs | Partitioned on the created_at of the event or job it was stored for, so it is dropped with that month. Holds the text itself, or a reference when the payload was offloaded to the payload store |
msg_events_read, msg_dispatch_jobs_read |
Denormalised copies for lists and filters | Partitioned. Written only by the stream processor. The job copy omits the payload |
msg_scheduled_job_instances, msg_scheduled_job_instance_logs |
Each firing of a scheduled job and its log lines | Partitioned, shorter retention |
msg_scheduled_job_ticks |
One row per job per cron tick | Makes “exactly one firing per tick” hold in the database |
Write tables and read projections
Section titled “Write tables and read projections”The platform separates the tables it writes from the tables it lists. msg_events and
msg_dispatch_jobs stay narrow and are indexed for the write path, the scheduler’s claim and the
hold-back checks. The *_read tables carry the derived columns (application, subdomain and
aggregate split from the type or code, is_completed, is_terminal) and the indexes the console’s
grids and filters need. The stream processor copies rows across within about a second. The cost is
a short read lag on lists; the gain is that a heavy filter on the console never competes with the
indexes the delivery path depends on. See stream processor.
Partitioning and retention
Section titled “Partitioning and retention”High-volume tables are range-partitioned by month on created_at (<table>_YYYY_MM):
| Table | Retention (default) | Managed by |
|---|---|---|
msg_events, msg_events_read, msg_payloads |
90 days (FC_STREAM_PARTITION_RETENTION_DAYS) |
Stream processor’s partition manager |
msg_dispatch_jobs, msg_dispatch_jobs_read, msg_dispatch_job_attempts |
90 days | The same |
msg_scheduled_job_instances, msg_scheduled_job_instance_logs |
30 days (FC_STREAM_PARTITION_RETENTION_DAYS_SCHEDULED_JOBS) |
The same |
iam_login_attempts |
3 years, quarterly partitions | The platform’s housekeeping loop |
Old data is removed by dropping a whole partition, never by DELETE. At this volume a batched
DELETE writes as much WAL as it removes, competes with ingest for I/O and leaves vacuum work behind;
dropping a partition is close to free. A partition is dropped only once its whole month is older than
the retention, so the data kept floats between the retention period and one month more.
Every primary and unique key on a partitioned table includes created_at, because PostgreSQL
requires the partition key in every unique index. Two consequences:
- A job or event is addressed by
(id, created_at). The lifecycle’s statements carry both, so each touches one partition. - Event deduplication cannot rely on the unique index alone (a retry has a new
created_at). Ingest looks up thededuplication_idacross the table first and drops repeats; the index is the last line of defence. The window between the lookup and the insert is accepted, because the retries deduplication exists for (an outbox resending a batch) are sequential.
Everything else is removed by bounded, idempotent sweeps that run on every platform replica (no leader needed):
| Sweep | Cadence | Removes |
|---|---|---|
| Auth purger | Every minute | Expired OAuth payloads, OIDC login states, passkey ceremonies, portal login flows, expired email PINs, trusted devices and password-reset tokens, reset-approval requests 90 days after they end, field nonces, enrolment codes and old sessions, field sign-in attempts past FC_FIELD_LOGIN_ATTEMPT_RETENTION_DAYS (90), rate-limit events past the longest window, lapsed previous client secrets |
| Dispatch-job key retention | Every 10 minutes | Idempotency keys older than 7 days |
| Function trace retention | FC_FUNCTIONS_TRACE_PRUNE_INTERVAL_MINUTES (60) |
Trace records past FC_FUNCTIONS_TRACE_RETENTION_DAYS (30) |
| Ingestion retention | Periodic, when ingestion is enabled | Runtime metrics and failures (30 days), test requests (a day), expired leases, runtimes unseen for 7 days |
aud_logs is not partitioned and has no retention sweep: audit history is kept until you decide
otherwise. Plan for its growth (see database operations).
Identifiers
Section titled “Identifiers”Primary keys are TSIDs: 13-character, time-sortable identifiers generated by the platform.
Entities exposed through the API carry a typed prefix (clt_, prn_, app_ and so on) and are
stored as VARCHAR(17). The high-volume messaging tables (events, dispatch jobs, attempts and their
projections) store the bare 13-character TSID in a VARCHAR(13) column.
Because a TSID grows with time, id is a stable tiebreak after created_at in every ordered scan.
See identifiers and the prefix reference.
Constraints
Section titled “Constraints”Enumerations are checked in the database. Every status, mode and kind column has a CHECK
constraint listing exactly the values its Go type defines (migrations 051 and 052), so an
unrecognised value fails loudly at write time instead of being coerced on read.
Foreign keys: the policy and the state. The ruling of 2026-11-10 (foreign keys only on master data): foreign keys may stay on master and configuration data, never on transactional or partition-candidate tables, and a new table does not get one by default. How that is applied:
- No foreign key on any transactional table: events, dispatch jobs and their attempts, keys and projections, traces, logs, login attempts, sessions, tokens, challenges, leases, runtime reports, push ids, audit and outbox tables. A deleted parent’s rows are removed by the parent’s delete path or left for retention to sweep, and an insert pays for no parent lookup. Migration 114 dropped the last eight constraints on such tables.
- Master and configuration data keep theirs: role permissions and assignments, MFA and passkey records, OAuth client child tables, OpenAPI specs, function versions and aliases, ingestion definitions, field-identity grants and the push configuration tables. Both ends of a key are master data.
- New cross-aggregate links are plain columns, for example a dispatch pool’s owning application or a field identity’s linked platform user. A dangling reference is shown as unresolvable rather than prevented.
- The permitted list is enforced by an integration test that fails on any foreign key not on it.
No extensions. The schema uses only core PostgreSQL: no pg_partman, pg_cron, uuid-ossp or
PostGIS in the platform’s own tables. Partition upkeep runs in process. See
no PostgreSQL extensions.
Migrations
Section titled “Migrations”The schema is created and upgraded by the platform itself. internal/migrate embeds the numbered
sql/NNN_subject.sql files and applies them with goose at
start-up, before anything else runs. Migrations are forward only.
Before goose runs, a bootstrap step makes goose’s ledger agree with the schema that is actually
present, so an existing database is never re-migrated (two early migrations drop and recreate the
messaging tables) and a migration is never recorded as applied without its effect. It recognises an
older ledger, or a populated schema with no ledger, and seeds only the versions whose effect it can
see (probes.go). From migration 031 every migration is re-runnable.
Queries are written in SQL and compiled to typed Go with sqlc; dynamic filters use a small WHERE-clause builder. See sqlc and goose.
Large-table changes are made online. A migration that touches a large table sets a
lock_timeout, adds indexes CONCURRENTLY (or, on a partitioned parent, per partition through an ops
script run before the deploy), adds constraints NOT VALID and validates them separately, backfills
in batches, and states its lock and expected duration in its header. See
online schema changes and
database operations.
Read next
Section titled “Read next”- Stream processor: projections and the partition manager.
- Dispatch scheduler: how the job table is claimed.
- Database operations and backup and disaster recovery.
- Runbook: database growth.
- Decisions: sqlc and goose, foreign keys only on master data, online schema changes, no PostgreSQL extensions, TSIDs with typed prefixes.