Skip to content

Data model ​

Registry stores everything in a single PostgreSQL database. The schema is managed by Flyway migrations (from V1_0_0 to V1_29_0), applied at startup; runtime access is reactive via R2DBC. This page is the physical-schema counterpart of the business-oriented Domain model.

Overview of entity relationships ​

All tables except tb_user, tb_preferences, tb_audit and the RBAC tables carry a project_id foreign key — the project is the tenant boundary, and most foreign keys to a project cascade on delete.

Conventions ​

  • Primary keys are UUIDs.
  • Auditing. Every domain table has created_date, created_by, last_modified_date, last_modified_by (the *_by columns reference tb_user), filled in by R2DBC auditing.
  • Soft delete. A visible BOOLEAN column implements soft delete / restore (or block / unblock for users and profiles). A "soft" delete never removes a row; it flips visible, which the authority model reads for visibility filtering.
  • Separate date/time. Windows and event times are stored in distinct _date DATE and _time TIME WITH TIME ZONE columns (the domain models them as CustomDateTime), so a value can be a plain date.
  • Trigram search. Searchable tables carry a STORED GENERATED search_text column with a gin_trgm_ops GIN index — see below.

Tables ​

Identity and preferences ​

TableKey columnsNotes
tb_useroidc_id (unique), type (USER/SERVICE_ACCOUNT), first_name, last_name, email (unique), role → tb_user_role, birthday, last_login, visibleGlobal identity. visible=false means blocked. Accounts are deleted for good (the former purged anonymization flag was removed in V1_16_0). A partial unique index enforces a single SERVICE_ACCOUNT. search_text = name + email.
tb_preferencesuser_id (unique) → tb_user (cascade), theme, language, refresh_modeOne row per user; interface preferences only. refresh_mode (OFF/ECO/NORMAL/FAST, NORMAL by default) sets the automatic data refresh frequency. The active profile column was removed in V1_14_0.

Project and membership ​

TableKey columnsNotes
tb_projectname, begin_date/begin_time, end_date/end_time, options TEXT[]The tenant root. options lists the enabled modules (VEHICLE, ACTIVITY, COMMUNICATION, ALERT).
tb_project_favoriteuser_id → tb_user (cascade), project_id → tb_project (cascade), created_dateA user's favorite projects; unique per (user_id, project_id). Added in V1_19_0.
tb_project_profileuser_id → tb_user (cascade), project_id → tb_project (cascade), role → tb_project_role (cascade), status, start_access_*/end_access_*A user's membership: role, invitation status (INVITED/ACCEPTED/REJECTED/BLOCKED) and access window.

Participants and groups ​

TableKey columnsNotes
tb_participantfirst_name, last_name, birthday (not null), type (REGISTERED/GUEST), user_id → tb_user (set null), project_id (cascade), start/end_availability_*, effective_arrival, effective_departureA person at the event, optionally linked to a user. The effective dates are the first check-in and the last definitive check-out (or a guest's last check-out) taken from movements, maintained when movements change (V1_18_0). search_text = name. Presence status is derived from movements, not stored; the effective dates are the only stored derivation.
tb_groupname, project_id (cascade), start/end_availability_*A named set of participants.
tb_group_contentPK (group_id, participant_id), both cascadingMany-to-many group ↔ participant relationship.

Movements (core) ​

TableKey columnsNotes
tb_movementdate_time, type (IN/OUT), project_id (cascade), activity_id → tb_activity, reasonA check-in/check-out event, justified either by a reason or by an activity_id (never both).
tb_movement_contentPK (movement_id, participant_id), pool_name (nullable VARCHAR), vehicle_id → tb_vehicleThe people moved. pool_name is the name of the group expanded to produce this entry, frozen at recording time; it is NULL for a participant added individually, and is independent of vehicle_id.

Optional modules ​

TableKey columnsNotes
tb_vehiclelicense_plate, brand, model, project_id (cascade), start/end_availability_*search_text = plate + make + model. Presence derived from movements.
tb_activityname, description, duration, min_allowed_participants, max_allowed_participants, project_id (cascade), start/end_availability_*Usable as a movement reason. search_text = name + description.
tb_communicationdate_time, message, movement_id → tb_movement (cascade, nullable), alert_id → tb_alert (set null), project_id (cascade)A message attached to a movement and/or an alert (at least one of the two).
tb_alertdate_time, title, status (IN_PROGRESS/RESOLVED/CANCELED), project_id (cascade)An incident with its own communication thread.

Log history ​

Before each change to a log-type item, its previous state is copied into a history table (ADR 018).

TableKey columnsNotes
tb_movement_historymovement_id (cascade), version, archived_date, copy of the movement's fieldsUnique per (movement_id, version).
tb_movement_content_historymovement_history_id (cascade), participant_id, vehicle_id, pool_nameThe movement's content at that version.
tb_alert_historyalert_id (cascade), version, archived_date, copy of the title, status and dateStatus changes are archived too.
tb_communication_historycommunication_id (cascade), version, archived_date, copy of the message and links—

Audit ​

TableKey columnsNotes
tb_auditaction (READ/EXPORT), resource_type (USER/PARTICIPANT/MOVEMENT), resource_id, project_id, actor_user_id, outcome (SUCCESS/FORBIDDEN/RATE_LIMITED), client_ip, user_agent, occurred_atTrace of access to personal data (ADR 019). Deliberately without foreign keys: the trace survives the deletion of the actor or the resource, until its own purge. Indexed by actor, by resource and by date.

RBAC (roles and permissions as data) ​

Two parallel sets of three tables encode the two permission planes:

Global planeProject planePurpose
tb_user_permission (name)tb_project_permission (name)The catalog of permission names.
tb_user_role (name, level)tb_project_role (name, level)The roles, with a numeric level (lower = more powerful). A partial unique index enforces exactly one level-0 role.
tb_user_role_permission (role, permission)tb_project_role_permission (role, permission)The role → permission mapping.

Each resource has its create, read, update and permanent delete permissions, plus dedicated soft delete and restore permissions (V1_28_0, ADR 017), history and metadata permissions. These rows are injected by the _roles migrations and loaded into memory at startup; changing them is a data operation (and a restart) rather than a code change (ADR 005).

V1_4_0 adds fuzzy search without a separate search engine (ADR 006):

  • the pg_trgm extension is enabled;
  • tb_user, tb_participant, tb_vehicle and tb_activity each gain a STORED GENERATED search_text column that concatenates their human-identifying fields;
  • each search_text gets a GIN gin_trgm_ops index for fast substring/approximate search.

Result set sizes are bounded by configuration to keep search cheap.

Migration history ​

MigrationAdds
V1_0_0 / V1_0_1Initial structure; base user roles
V1_1_0 / V1_1_1Groups; group roles
V1_2_0 / V1_2_1Vehicles; vehicle roles
V1_3_0 / V1_3_1Activities; activity roles
V1_4_0Trigram search columns and indexes
V1_5_0Movement reason
V1_6_0Guest participant type
V1_7_0 / V1_7_1Communication structure; communication roles
V1_8_0 / V1_8_1Alert structure; alert roles
V1_9_0Scheduled job (purge) role
V1_10_0Preference improvements
V1_11_0Removal of the service account's email
V1_12_0Fix of the activity indexes (moved from tb_vehicle to tb_activity)
V1_13_0Trigram search on alert titles and communication messages
V1_14_0Removal of the active profile stored in preferences
V1_15_0Removal of the REGISTRY_PROJECT_METADATA_R permission (options moved to the public metadata API)
V1_16_0Removal of anonymization: deletion of anonymized rows, removal of purged
V1_17_0REGISTRY_PROJECT_PARTICIPANT_EXPORT permission (project administrators)
V1_18_0Participants' effective arrival and departure dates (back-computed from movements)
V1_19_0Project favorites
V1_20_0Index on movements (project_id, date_time)
V1_21_0Search indexes on movement and group content by participant
V1_22_0Preferences refresh mode
V1_23_0Coordinators lose permanent deletion of movements
V1_24_0Indexes on foreign keys (a movement's activity and vehicle, a communication's alert)
V1_25_0History tables for movements, alerts and communications
V1_26_0Audit table for access to personal data
V1_27_0Index on lowercase email (exact search for a user to invite)
V1_28_0Soft delete and restore permissions, for users and each project resource
V1_29_0Unlinks participants attached to a user who has no profile on their project

Migrations are forward-only. Any new schema change goes into a new V… file, never by editing an already applied migration.