Skip to Content
Trips Enjoy
Data Model (ERD)

Data Model

Conventions, domain map and entry points into the entity-relationship design.

Trips Enjoy: Entity-Relationship Design (ERD)

These apply to every table unless the table says otherwise.

RuleDetail
Primary keyid BIGSERIAL (internal only, never exposed).
Public identifieruuid UUID NOT NULL DEFAULT gen_random_uuid() UNIQUE. APIs, URLs, webhooks and exports use uuid only.
Timestampscreated_at, updated_at, deleted_at as TIMESTAMPTZ. All times are stored in UTC.
Soft deleteis_deleted BOOLEAN NOT NULL DEFAULT false plus deleted_at. Unique constraints include deleted_at (for example UNIQUE (code, deleted_at)).
Audit columnscreated_by, updated_by, deleted_by as BIGINT FKs to users.id.
No enum typesEvery status, type and category is a BIGINT FK to lookups.id (named *_id, for example status_id). The lookup type is named in the column notes.
Tenant columnEvery row owned by an organization carries organization_id BIGINT NOT NULL, indexed, with an RLS policy on app.current_organization_id (SRS DAT-01, NFR-SEC-07). Child tables repeat organization_id (denormalized) so RLS never needs a join.
Money*_minor BIGINT in minor units plus currency_code CHAR(3) FK currencies.code. Never a float, never a bare number (D-157).
Translatable textJSONB shaped {"en": "...", "ar": "..."} for names and descriptions shown to users.
Countrycountry_code CHAR(2) FK countries.code (ISO 3166-1 alpha-2).
Immutable tablesledger_entries, ledger_transactions, audit_logs, deal_offers, checkin_events, tracking_points, consents, outbox_events: insert only. They keep created_at and created_by but have no updated_*, deleted_* or is_deleted. Corrections are new reversing rows (SRS DAT-08).
Time-seriescheckin_events and tracking_points are TimescaleDB hypertables partitioned on occurred_at; primary key (id, occurred_at).
Encrypted columnsColumns marked "enc" are encrypted at column level with KMS (SRS DAT-05). A *_hash column next to them supports lookups.

Base columns are not repeated in the tables below. "Base" means: id, uuid, created_at, updated_at, deleted_at, is_deleted, created_by, updated_by, deleted_by.

DomainTablesSection
Lookups and marketslookup_types, lookups, countries, currencies, markets, market_payment_methods, tax_rates3.1
Identity and accessusers, user_roles, auth_factors, otp_challenges, sessions, devices, consents, notification_preferences, privacy_requests3.2
Applicationsapplications, application_documents, application_decisions, appeals3.3
Organizationsorganizations, organization_members, permissions, member_permissions, invitations, crm_connections, webhook_endpoints, webhook_deliveries, api_keys3.4
Suppliersdriver_profiles, photographer_profiles, provider_vehicles, availability_slots, portfolio_items, lab_partners, lab_tests, payout_methods3.5
Fleet and tripsvehicle_types, vehicle_type_seats, vehicles, trips, trip_stops, trip_audiences, trip_vehicles, trip_staff_assignments, programs, program_tiers3.6
Dealsdeals, deal_offers3.7
Booking and paymentbookings, booking_passengers, booking_programs, trip_seats, payments, payment_attempts, refunds, booking_remedies3.8
Couponscoupons, coupon_programs, coupon_audiences, coupon_redemptions, abuse_flags3.9
Plansplans, plan_limits, plan_prices, subscriptions, subscription_charges, plan_overrides, usage_counters3.10
Operationscheckin_events, incidents, trip_reports, tracking_points, child_links, safety_cases3.11
Mediaalbums, photos, album_shared_links, album_members, download_logs3.12
Financeledger_accounts, ledger_transactions, ledger_entries, invoices, invoice_lines, payout_runs, payouts, settlements, settlement_lines, reconciliation_exceptions, disputes, dispute_files3.13
Platformnotifications, notification_deliveries, notification_templates, feature_flags, analytics_events, analytics_daily, audit_logs, outbox_events, idempotency_keys3.14

Domains

On this page