Skip to Content
Trips Enjoy
Data Model (ERD)Domains

Operations

Tables and relationships for the operations domain.

Part of the data model; conventions and base columns are documented there.

checkin_events

(immutable hypertable) FR-CHK-01 to FR-CHK-05

ColumnTypeNotes
id, uuidBIGSERIAL, UUIDPrimary key (id, occurred_at)
organization_idBIGINT
trip_idBIGINT
trip_vehicle_idBIGINT
passenger_idBIGINT FK booking_passengers
event_type_idBIGINT FK lookupscheckin_event: check_in, check_out, refused_wrong_vehicle
stop_idBIGINT FK trip_stops NULL
moderator_user_idBIGINT FK users
lat, lng, accuracy_mNUMERIC, NUMERIC, REALNull when location is not permitted
occurred_atTIMESTAMPTZDevice time of the event
received_atTIMESTAMPTZServer time; difference measures the 60-second target
client_event_idUUIDUnique; offline replay is idempotent
created_at, created_by

Retention 1 year.

tracking_points (immutable hypertable) FR-TRK-01, FR-TRK-02: id, organization_id, trip_vehicle_id, occurred_at, lat, lng, speed_kmh REAL, heading SMALLINT, accuracy_m REAL, source_id FK lookups (gps_source: driver_app, moderator_app). Retention 90 days, then an hourly summary is kept.

incidents (Base +) FR-CHK-06: organization_id, trip_id, trip_vehicle_id, reported_by FK users, category_id FK lookups (incident_category: safety, medical, vehicle_fault, lost_traveler, conduct, other), severity_id FK lookups (severity), description TEXT, attachments JSONB, lat, lng, status_id FK lookups (incident_status: open, acknowledged, resolved), acknowledged_at, resolved_at.

trip_reports (Base +) FR-MOD-02, FR-MOD-06: organization_id, trip_vehicle_id FK UNIQUE, moderator_user_id, checked_in_count INT, final_headcount INT, mismatch_reason TEXT, notes TEXT, submitted_at (locked after), org_note TEXT.

(Base +) FR-PAR-01 to FR-PAR-06

ColumnTypeNotes
parent_user_idBIGINT FK users
booking_idBIGINT FK bookings
passenger_idBIGINT FK booking_passengersMust be is_child
organization_idBIGINTCopied for RLS on organization reads
guardianship_consent_idBIGINT FK consentsD-126
status_idBIGINT FK lookupschild_link_status: active, ended
ended_atTIMESTAMPTZEnds on cancellation or refund

Unique active (parent_user_id, passenger_id).

safety_cases (Base +) FR-PAR-07: organization_id, trip_id FK, passenger_id FK NULL, reported_by FK users, reporter_role_id FK lookups (role), description TEXT, status_id FK lookups (case_status: open, escalated, closed), escalated_to VARCHAR(200) (D-68), escalated_at, closed_at.

On this page