Skip to Content
Trips Enjoy
Data Model (ERD)Domains

Fleet and trips

Tables and relationships for the fleet and trips domain.

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

vehicle_types (Base +) FR-FLT-01, FR-FLT-06: organization_id, name JSONB, seat_count SMALLINT, layout JSONB (grid rows, columns, aisles, doors), archived_at TIMESTAMPTZ.

vehicle_type_seats (Base +): organization_id, vehicle_type_id FK, label VARCHAR(10) (for example 12B), row_no SMALLINT, col_no SMALLINT, seat_kind_id FK lookups (seat_kind: standard, accessible, crew, blocked). Unique (vehicle_type_id, label, deleted_at).

vehicles (Base +) FR-FLT-02: organization_id, vehicle_type_id FK, plate_no VARCHAR(20), model VARCHAR(80), year SMALLINT, seat_count SMALLINT (must equal the type), registration_status_id FK lookups (registration_status), registration_valid_until DATE, provider_vehicle_id FK provider_vehicles NULL (a platform driver's own vehicle used on a deal).

trips

(Base +) FR-TRIP-01 to FR-TRIP-07

ColumnTypeNotes
organization_idBIGINT FK organizationsTenant column
market_idBIGINT FK marketsCopied from the organization at creation
codeVARCHAR(20)Human reference, unique per organization
title, descriptionJSONB
category_idBIGINT FK lookupstrip_category
status_idBIGINT FK lookupstrip_status: draft, published, negotiating, ready, filling_up, sold_out, in_progress, partially_completed, completed, post_processing, archived, cancelled, refunds_issued
publish_mode_idBIGINT FK lookupspublish_mode: draft, public, targeted
timezoneVARCHAR(64)
starts_at, ends_atTIMESTAMPTZ
base_price_minorBIGINT
currency_codeCHAR(3)From market
capacity_totalINTSum of vehicle seats
seats_reservedINTCounter; Filling Up at 80 percent (D-189)
seat_mode_idBIGINT FK lookupsseat_mode: company_assigned, self_select
child_tracking_enabledBOOLEANFR-TRK-04
vip_early_access_untilTIMESTAMPTZ NULLD-146
priority_seat_window_untilTIMESTAMPTZ NULLD-316
published_at, cancelled_at, completed_at, archived_atTIMESTAMPTZ
cancel_reasonTEXT
counted_in_cycleDATEMonth counted for the active-trip limit (D-143)

Indexes: (organization_id, status_id), partial (starts_at) where published or filling up.

trip_stops (Base +): organization_id, trip_id FK, seq SMALLINT, kind_id FK lookups (stop_kind: pickup, stop, destination, dropoff), name JSONB, address JSONB, lat NUMERIC(10,7), lng NUMERIC(10,7), planned_at TIMESTAMPTZ.

trip_audiences (Base +): organization_id, trip_id FK, user_id FK NULL, email CITEXT NULL, phone_hash CHAR(64) NULL. Targeted publishing list (FR-TRIP-02).

trip_vehicles

(Base +) FR-TRIP-03

ColumnTypeNotes
organization_idBIGINTTenant column
trip_idBIGINT FK trips
vehicle_idBIGINT FK vehicles NULL
vehicle_type_idBIGINT FK vehicle_types
labelVARCHAR(40)Bus A, Bus B
status_idBIGINT FK lookupstrip_vehicle_status: planning, ready, departed, ended
seat_countSMALLINT
departed_at, ended_atTIMESTAMPTZ
last_lat, last_lng, last_point_atNUMERIC, NUMERIC, TIMESTAMPTZLatest position cache

trip_staff_assignments

(Base +) FR-STF-01 to FR-STF-05

ColumnTypeNotes
organization_idBIGINT
trip_idBIGINT FK trips
trip_vehicle_idBIGINT FK trip_vehicles NULLNull for trip-level photographer
staff_role_idBIGINT FK lookupsstaff_role: driver, moderator, photographer
user_idBIGINT FK users
track_idBIGINT FK lookupssupplier_track: organization, platform
deal_idBIGINT FK deals NULLRequired when track is platform (BRL-04)
status_idBIGINT FK lookupsassignment_status: proposed, accepted, replaced, released
access_untilTIMESTAMPTZModerators: trip end plus 24 h (D-107)

Unique active (trip_vehicle_id, staff_role_id) where status accepted.

programs

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

ColumnTypeNotes
organization_idBIGINT
trip_idBIGINT FK trips
title, descriptionJSONB
pricing_model_idBIGINT FK lookupspricing_model: free, per_person, by_quantity, per_group, tiered
price_minorBIGINT NULLNull for free and tiered
currency_codeCHAR(3)
is_requiredBOOLEANPre-required
is_vip_onlyBOOLEAN
capacityINT NULL
enrolled_countINT
starts_atTIMESTAMPTZ NULL

program_tiers (Base +): organization_id, program_id FK, name JSONB, price_minor BIGINT, sort_by INT.

On this page