Skip to content

iDrv5-MyFR8 Database Schema Documentation

**Database**: PostgreSQL 15+ **Server**: Supabase (aws-1-ap-northeast-2.pooler.supabase.com) **Database Name**: postgres **Total Tables**: 69+ **Total Inde…

Database: PostgreSQL 15+ Server: Supabase (aws-1-ap-northeast-2.pooler.supabase.com) Database Name: postgres Total Tables: 69+ Total Indexes: 100+


  1. Overview
  2. Entity Relationship Diagrams
  3. Schema Details by Module
  4. Key Relationships
  5. Indexes and Performance
  6. Reference Data
  7. Audit and Timestamps

The iDrv5-MyFR8 platform uses a comprehensive PostgreSQL database schema designed for multi-tenant SaaS logistics management. The schema is organized into seven functional modules:

ModuleTablesPurpose
Core12Tenants, companies, users, customers
Transport9Zones, rates, surcharges, bookings, quotes
Asset Management9Vehicles, fleets, maintenance, fuel, tracking
Workflow9Workflow definitions, instances, states, rules
Operations11LTL, linehaul, dispatch, manifests, pallets
Compliance10Certifications, incidents, training, audits
Staff Management8Profiles, schedules, leave, performance

erDiagram
TENANTS ||--o{ COMPANIES : "hosts"
TENANTS ||--|| TENANT_SETTINGS : "has"
COMPANIES ||--o{ USERS : "employs"
COMPANIES ||--o{ CUSTOMERS : "serves"
CUSTOMERS ||--o{ CUSTOMER_ADDRESSES : "has"
USERS ||--o{ NOTIFICATIONS : "receives"
TENANTS {
serial id PK
uuid tenant_id UK
varchar company_name
varchar subdomain UK
varchar status
varchar plan_type
timestamp subscription_start
timestamp subscription_end
}
TENANT_SETTINGS {
serial id PK
uuid tenant_id FK
varchar logo_url
varchar primary_color
varchar region
varchar timezone
varchar currency
text[] enabled_modules
jsonb module_settings
}
COMPANIES {
serial id PK
uuid uuid UK
uuid tenant_id FK
varchar name
varchar abn
varchar company_code UK
varchar status
boolean is_customer
boolean is_transport_company
jsonb enabled_modules
}
USERS {
serial id PK
uuid uuid UK
integer company_id FK
varchar username UK
varchar email UK
varchar password_hash
varchar role
text[] permissions
boolean is_active
boolean is_super_admin
}
CUSTOMERS {
serial id PK
uuid uuid UK
integer company_id FK
varchar name
varchar account_number UK
varchar status
decimal credit_limit
boolean is_active
}
CUSTOMER_ADDRESSES {
serial id PK
integer customer_id FK
varchar address_type
varchar address_line1
varchar suburb
varchar state
varchar postcode
boolean is_default
jsonb operating_hours
}
NOTIFICATIONS {
serial id PK
integer user_id FK
varchar title
text message
varchar notification_type
boolean is_read
jsonb data
}
erDiagram
COMPANIES ||--o{ ZONES : "defines"
COMPANIES ||--o{ SERVICE_LEVELS : "offers"
COMPANIES ||--o{ SURCHARGES : "applies"
CUSTOMERS ||--o{ RATE_CARDS : "has"
RATE_CARDS ||--o{ RATE_ENTRIES : "contains"
ZONES ||--o{ ZONE_SUBURBS : "includes"
ZONES ||--o{ RATE_ENTRIES : "origin"
ZONES ||--o{ RATE_ENTRIES : "destination"
SERVICE_LEVELS ||--o{ RATE_ENTRIES : "priced_by"
SURCHARGES ||--o{ CUSTOMER_SURCHARGES : "customized"
CUSTOMERS ||--o{ CUSTOMER_SURCHARGES : "has"
CUSTOMERS ||--o{ BOOKINGS : "creates"
CUSTOMERS ||--o{ QUOTES : "requests"
CUSTOMERS ||--o{ UNIFIED_QUOTES : "requests"
ZONES {
serial id PK
integer company_id FK
varchar name
varchar short_name
varchar code UK
varchar zone_type
varchar state
text boundary_geojson
decimal center_lat
decimal center_lng
varchar service_flag
boolean is_active
}
ZONE_SUBURBS {
serial id PK
integer zone_id FK
varchar suburb_name
varchar postcode
varchar state_code
decimal latitude
decimal longitude
}
SERVICE_LEVELS {
serial id PK
integer company_id FK
varchar name
varchar description
integer priority
decimal base_cost_multiplier
decimal transit_time_multiplier
boolean is_active
}
RATE_CARDS {
serial id PK
integer customer_id FK
varchar name
varchar rate_type
varchar description
date effective_date
date expiry_date
boolean is_active
}
RATE_ENTRIES {
serial id PK
integer rate_card_id FK
integer origin_zone_id FK
integer destination_zone_id FK
integer service_level_id FK
decimal rate_per_kg
decimal rate_per_pallet
decimal flat_rate
decimal minimum_charge
integer transit_time_hours
boolean is_active
}
SURCHARGES {
serial id PK
integer company_id FK
varchar name
varchar type
decimal amount
decimal percentage
varchar applies_to
boolean is_active
}
CUSTOMER_SURCHARGES {
serial id PK
integer customer_id FK
integer surcharge_id FK
boolean is_enabled
varchar adjustment_type
decimal adjustment_value
}
BOOKINGS {
serial id PK
integer company_id FK
integer customer_id FK
varchar booking_number UK
integer service_level_id FK
varchar job_type
varchar status
date pickup_date
date delivery_date
decimal total_amount
}
QUOTES {
serial id PK
integer company_id FK
integer customer_id FK
varchar quote_number UK
varchar status
date valid_until
decimal total_amount
}
UNIFIED_QUOTES {
serial id PK
integer company_id FK
integer customer_id FK
varchar quote_number UK
varchar origin_suburb
varchar dest_suburb
decimal weight
decimal total_amount
varchar status
}
erDiagram
CUSTOMERS ||--o{ LTL_BOOKINGS : "places"
USERS ||--o{ LTL_PICKUP_JOBS : "assigned_to"
VEHICLES ||--o{ LTL_PICKUP_JOBS : "uses"
LTL_BOOKINGS }o--|| LTL_PICKUP_JOBS : "collected_by"
LTL_BOOKINGS }o--|| CONSOLIDATION_MANIFESTS : "consolidated_in"
CONSOLIDATION_MANIFESTS }o--|| LINEHAUL_DISPATCHES : "dispatched_via"
USERS ||--o{ LINEHAUL_DISPATCHES : "driven_by"
VEHICLES ||--o{ LINEHAUL_DISPATCHES : "uses"
LTL_BOOKINGS }o--|| DELIVERY_MANIFESTS : "delivered_by"
USERS ||--o{ DELIVERY_MANIFESTS : "driver"
VEHICLES ||--o{ DELIVERY_MANIFESTS : "vehicle"
USERS ||--o{ DRIVER_MANIFESTS : "has"
DRIVER_MANIFESTS ||--o{ MANIFEST_SHIPMENTS : "contains"
DISPATCH_CENTERS ||--o{ DISPATCH_JOBS : "manages"
USERS ||--o{ DISPATCH_JOBS : "assigned_driver"
VEHICLES ||--o{ DISPATCH_JOBS : "assigned_vehicle"
DISPATCH_JOBS ||--o{ JOB_STATUS_UPDATES : "tracks"
PALLET_TYPES ||--o{ PALLET_TRACKING : "defines"
LTL_BOOKINGS {
serial id PK
varchar booking_reference UK
integer customer_id FK
varchar booking_status
timestamp pickup_date_requested
timestamp delivery_date_requested
decimal total_weight
integer pallet_count
varchar pallet_type
}
LTL_PICKUP_JOBS {
serial id PK
varchar job_reference UK
integer driver_id FK
integer vehicle_id FK
varchar job_status
timestamp estimated_pickup_time
timestamp actual_pickup_time
}
CONSOLIDATION_MANIFESTS {
serial id PK
varchar manifest_reference UK
date consolidation_date
varchar warehouse_location
varchar manifest_status
integer total_ltl_bookings
decimal total_weight
}
LINEHAUL_DISPATCHES {
serial id PK
varchar dispatch_reference UK
varchar origin_depot
varchar destination_depot
integer primary_driver_id FK
integer vehicle_id FK
varchar dispatch_status
timestamp scheduled_departure
}
DELIVERY_MANIFESTS {
serial id PK
varchar manifest_reference UK
date delivery_date
integer driver_id FK
integer vehicle_id FK
varchar manifest_status
integer total_deliveries
}
DRIVER_MANIFESTS {
serial id PK
integer driver_id FK
varchar manifest_code UK
varchar vehicle_registration
boolean is_active
timestamp shift_start
timestamp shift_end
}
MANIFEST_SHIPMENTS {
serial id PK
integer manifest_id FK
integer booking_id
varchar status
integer delivery_sequence
boolean requires_signature
timestamp delivered_at
}
DISPATCH_CENTERS {
serial id PK
varchar center_name
varchar location
decimal coverage_radius_km
boolean is_active
jsonb operating_hours
}
DISPATCH_JOBS {
serial id PK
varchar job_reference UK
integer dispatch_center_id FK
varchar job_type
varchar priority
integer assigned_driver_id FK
integer assigned_vehicle_id FK
varchar job_status
}
JOB_STATUS_UPDATES {
serial id PK
integer job_id FK
varchar old_status
varchar new_status
decimal latitude
decimal longitude
timestamp status_timestamp
}
PALLET_TYPES {
serial id PK
varchar name
varchar standard_size
integer length_mm
integer width_mm
decimal max_weight_kg
boolean is_active
}
PALLET_TRACKING {
serial id PK
varchar pallet_id UK
integer pallet_type_id FK
varchar current_status
varchar current_location
integer total_uses
decimal deposit_amount
}
erDiagram
COMPANIES ||--o{ FLEETS : "owns"
FLEETS ||--o{ VEHICLES : "contains"
VEHICLES ||--o{ MAINTENANCE_RECORDS : "has"
VEHICLES ||--o{ VEHICLE_INSPECTIONS : "undergoes"
VEHICLES ||--o{ FUEL_RECORDS : "consumes"
MAINTENANCE_RECORDS ||--o{ MAINTENANCE_ITEMS : "includes"
USERS ||--o{ ASSET_TRACKING : "operates"
ASSETS {
serial id PK
varchar asset_code UK
varchar name
varchar asset_type
varchar status
date purchase_date
decimal purchase_cost
decimal current_value
varchar manufacturer
varchar model
}
FLEETS {
serial id PK
integer company_id FK
varchar name
varchar description
integer fleet_manager_id FK
boolean is_active
}
VEHICLES {
serial id PK
varchar registration UK
varchar make
varchar model
integer year
integer fleet_id FK
varchar vehicle_type
decimal capacity_weight
decimal capacity_volume
integer capacity_pallets
varchar status
decimal current_lat
decimal current_lng
date insurance_expiry
date registration_expiry
}
MAINTENANCE_RECORDS {
serial id PK
integer vehicle_id FK
varchar maintenance_type
text description
date maintenance_date
integer odometer_reading
decimal total_cost
varchar status
varchar priority
}
MAINTENANCE_ITEMS {
serial id PK
integer maintenance_record_id FK
varchar item_name
varchar part_number
integer quantity
decimal unit_cost
decimal total_cost
}
VEHICLE_INSPECTIONS {
serial id PK
integer vehicle_id FK
varchar inspection_type
date inspection_date
integer inspector_id FK
varchar overall_result
jsonb checklist_items
text defects_found
}
FUEL_RECORDS {
serial id PK
integer vehicle_id FK
date fuel_date
varchar fuel_type
decimal quantity_liters
decimal total_cost
integer odometer_reading
integer driver_id FK
decimal fuel_efficiency_kmpl
}
ASSET_TRACKING {
serial id PK
varchar asset_type
integer asset_id
decimal latitude
decimal longitude
timestamp tracked_at
varchar engine_status
decimal speed_kmh
integer driver_id FK
}
erDiagram
WORKFLOW_DEFINITIONS ||--o{ WORKFLOW_INSTANCES : "creates"
WORKFLOW_DEFINITIONS ||--o{ WORKFLOW_STATES : "defines"
WORKFLOW_DEFINITIONS ||--o{ WORKFLOW_RULES : "has"
WORKFLOW_INSTANCES ||--o{ WORKFLOW_TRANSITIONS : "records"
WORKFLOW_INSTANCES ||--o{ WORKFLOW_ASSIGNMENTS : "creates"
WORKFLOW_INSTANCES ||--o{ WORKFLOW_HISTORY : "logs"
WORKFLOW_INSTANCES ||--o{ WORKFLOW_NOTIFICATIONS : "triggers"
WORKFLOW_DEFINITIONS ||--o{ WORKFLOW_METRICS : "measured_by"
WORKFLOW_DEFINITIONS {
serial id PK
varchar name
varchar code UK
varchar entity_type
varchar version
varchar initial_state
jsonb states
jsonb transitions
boolean is_active
}
WORKFLOW_INSTANCES {
serial id PK
varchar reference_number
varchar entity_type
integer entity_id
integer workflow_definition_id FK
varchar current_state
varchar status
date due_date
integer company_id FK
jsonb workflow_data
}
WORKFLOW_STATES {
serial id PK
integer definition_id FK
varchar state_name
varchar display_name
varchar state_type
varchar color_code
boolean requires_approval
boolean auto_transition
}
WORKFLOW_RULES {
serial id PK
integer definition_id FK
varchar rule_name
varchar rule_type
varchar trigger_state
text condition_expression
varchar action_type
jsonb action_config
integer priority
}
WORKFLOW_TRANSITIONS {
serial id PK
integer instance_id FK
integer definition_id FK
varchar from_state
varchar to_state
varchar transition_name
integer user_id FK
timestamp transition_date
}
WORKFLOW_ASSIGNMENTS {
serial id PK
integer instance_id FK
varchar state_name
varchar assigned_to_user
varchar assigned_to_role
varchar task_name
varchar priority
date due_date
varchar status
}
WORKFLOW_HISTORY {
serial id PK
integer instance_id FK
varchar event_type
varchar old_state
varchar new_state
integer user_id FK
jsonb event_data
timestamp event_timestamp
}
WORKFLOW_NOTIFICATIONS {
serial id PK
integer instance_id FK
varchar notification_type
varchar recipient_type
varchar recipient_identifier
varchar subject
text message
varchar status
}
WORKFLOW_METRICS {
serial id PK
integer definition_id FK
integer instance_id FK
varchar metric_name
varchar metric_type
decimal metric_value
date measurement_date
}
erDiagram
COMPLIANCE_CATEGORIES ||--o{ ACCREDITATIONS : "categorizes"
COMPLIANCE_CATEGORIES ||--o{ STAFF_CERTIFICATIONS : "categorizes"
COMPANIES ||--o{ ACCREDITATIONS : "holds"
USERS ||--o{ STAFF_CERTIFICATIONS : "holds"
COMPANIES ||--o{ SAFETY_INCIDENTS : "reports"
COMPANIES ||--o{ TRAINING_PROGRAMS : "offers"
TRAINING_PROGRAMS ||--o{ TRAINING_RECORDS : "tracks"
USERS ||--o{ TRAINING_RECORDS : "attends"
COMPLIANCE_CATEGORIES ||--o{ COMPLIANCE_CHECKLISTS : "defines"
COMPLIANCE_CHECKLISTS ||--o{ CHECKLIST_ASSESSMENTS : "assessed_by"
COMPANIES ||--o{ REGULATORY_INSPECTIONS : "undergoes"
COMPLIANCE_CATEGORIES {
serial id PK
varchar category_name UK
varchar description
varchar regulatory_body
varchar category_type
boolean is_mandatory
boolean is_active
}
ACCREDITATIONS {
serial id PK
integer company_id FK
integer category_id FK
varchar accreditation_name
varchar accreditation_number
varchar issuing_authority
date issue_date
date expiry_date
varchar status
}
STAFF_CERTIFICATIONS {
serial id PK
integer user_id FK
integer category_id FK
varchar certification_name
varchar certification_number
date issue_date
date expiry_date
varchar status
varchar competency_level
}
SAFETY_INCIDENTS {
serial id PK
varchar incident_number UK
integer company_id FK
timestamp incident_date
varchar incident_type
varchar severity_level
text incident_description
varchar investigation_status
varchar status
}
TRAINING_PROGRAMS {
serial id PK
integer company_id FK
varchar program_name
varchar program_code UK
varchar program_type
integer duration_hours
varchar frequency_type
boolean provides_certification
boolean is_active
}
TRAINING_RECORDS {
serial id PK
integer program_id FK
integer user_id FK
date session_date
varchar attendance_status
decimal assessment_score
varchar assessment_result
varchar certificate_number
date certificate_expiry_date
}
COMPLIANCE_CHECKLISTS {
serial id PK
integer company_id FK
integer category_id FK
varchar checklist_name
varchar checklist_type
varchar frequency
jsonb checklist_items
decimal pass_threshold_score
boolean is_active
}
CHECKLIST_ASSESSMENTS {
serial id PK
integer checklist_id FK
integer assessed_by FK
date assessment_date
varchar assessment_type
decimal total_score
varchar overall_result
jsonb checklist_responses
varchar status
}
REGULATORY_INSPECTIONS {
serial id PK
integer company_id FK
varchar inspection_number UK
varchar inspection_type
varchar regulatory_body
date actual_date
varchar overall_result
decimal compliance_score
varchar status
}
COMPLIANCE_AUDIT_TRAILS {
serial id PK
varchar entity_type
integer entity_id
varchar action_type
jsonb old_values
jsonb new_values
integer user_id FK
timestamp action_timestamp
}
erDiagram
USERS ||--|| USER_PROFILES : "has"
USER_PROFILES ||--o{ CERTIFICATIONS : "holds"
USER_PROFILES ||--o{ SCHEDULES : "works"
USER_PROFILES ||--o{ TIME_RECORDS : "logs"
USER_PROFILES ||--o{ LEAVE_REQUESTS : "requests"
USER_PROFILES ||--o{ LEAVE_BALANCES : "tracks"
USER_PROFILES ||--o{ PERFORMANCE_REVIEWS : "receives"
USER_PROFILES ||--o{ DISCIPLINARY_ACTIONS : "receives"
USER_PROFILES {
serial id PK
integer user_id FK UK
varchar employee_id
date date_of_birth
varchar department
varchar position
integer reporting_manager_id FK
varchar employment_type
date start_date
decimal base_salary
decimal hourly_rate
jsonb availability
boolean is_active
}
CERTIFICATIONS {
serial id PK
integer user_profile_id FK
varchar certification_name
varchar certification_type
varchar issuing_authority
varchar certification_number
date issue_date
date expiry_date
varchar status
}
SCHEDULES {
serial id PK
integer user_profile_id FK
varchar schedule_name
varchar schedule_type
date effective_date
time shift_start_time
time shift_end_time
integer[] days_of_week
boolean is_active
}
TIME_RECORDS {
serial id PK
integer user_profile_id FK
date work_date
timestamp clock_in_time
timestamp clock_out_time
decimal regular_hours
decimal overtime_hours
decimal total_hours
varchar status
boolean payroll_processed
}
LEAVE_REQUESTS {
serial id PK
integer user_profile_id FK
varchar leave_type
date start_date
date end_date
decimal total_days
varchar reason
varchar status
integer reviewed_by FK
}
LEAVE_BALANCES {
serial id PK
integer user_profile_id FK
varchar leave_type
date balance_date
decimal opening_balance
decimal accrued_this_period
decimal used_this_period
decimal closing_balance
boolean is_current
}
PERFORMANCE_REVIEWS {
serial id PK
integer user_profile_id FK
date review_period_start
date review_period_end
varchar review_type
integer reviewer_id FK
varchar status
varchar overall_rating
decimal overall_score
jsonb action_items
}
DISCIPLINARY_ACTIONS {
serial id PK
integer user_profile_id FK
varchar incident_reference UK
date incident_date
varchar action_type
varchar severity_level
text incident_description
varchar status
date review_date
}

Multi-tenant support for SaaS model.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
tenant_idUUIDUNIQUE, DEFAULT uuid_generate_v4()Unique tenant identifier
company_nameVARCHAR(200)NOT NULLCompany name
subdomainVARCHAR(100)UNIQUETenant subdomain
statusVARCHAR(20)active, inactive, suspended
plan_typeVARCHAR(20)starter, growth, enterprise
admin_emailVARCHAR(255)Admin email
admin_nameVARCHAR(200)Admin name
phoneVARCHAR(50)Phone number
websiteVARCHAR(255)Website URL
address_line1VARCHAR(255)Address line 1
address_line2VARCHAR(255)Address line 2
cityVARCHAR(100)City
stateVARCHAR(100)State
postal_codeVARCHAR(20)Postal code
countryVARCHAR(100)Country
subscription_startTIMESTAMPSubscription start date
subscription_endTIMESTAMPSubscription end date
user_countINTEGERDEFAULT 0Number of users
last_loginTIMESTAMPLast login time
total_bookingsINTEGERDEFAULT 0Total bookings
monthly_bookingsINTEGERDEFAULT 0Monthly bookings
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp
created_byVARCHAR(100)Created by user

Indexes: idx_tenants_tenant_id, idx_tenants_subdomain, idx_tenants_status


Tenant-specific configuration and branding.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
tenant_idUUIDFK -> tenants.tenant_id, ON DELETE CASCADETenant reference
logo_urlVARCHAR(500)Logo URL
primary_colorVARCHAR(7)Primary brand color (hex)
accent_colorVARCHAR(7)Accent color (hex)
favicon_urlVARCHAR(500)Favicon URL
regionVARCHAR(2)ISO country code
timezoneVARCHAR(50)Timezone (e.g., Australia/Sydney)
currencyVARCHAR(3)Currency code (e.g., AUD)
date_formatVARCHAR(20)Date format string
time_formatVARCHAR(20)Time format string
quote_prefixVARCHAR(10)Quote number prefix
booking_prefixVARCHAR(10)Booking number prefix
connote_prefixVARCHAR(10)Connote number prefix
manifest_prefixVARCHAR(10)Manifest number prefix
quote_counterINTEGERDEFAULT 1Quote counter
booking_counterINTEGERDEFAULT 1Booking counter
connote_counterINTEGERDEFAULT 1Connote counter
manifest_counterINTEGERDEFAULT 1Manifest counter
enabled_modulesTEXT[]Enabled module list
module_settingsJSONBModule-specific settings
default_workflowsJSONBDefault workflow configurations
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_tenant_settings_tenant_id


Transport companies using the SaaS platform.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
uuidUUIDUNIQUEUnique identifier
tenant_idUUIDFK -> tenants.tenant_idTenant reference
nameVARCHAR(255)NOT NULLCompany name
trading_nameVARCHAR(255)Trading name
abnVARCHAR(20)Australian Business Number
company_codeVARCHAR(20)UNIQUEUnique company code
contact_nameVARCHAR(200)Primary contact name
contact_emailVARCHAR(255)Primary contact email
contact_phoneVARCHAR(50)Primary contact phone
address_line1VARCHAR(255)Address line 1
address_line2VARCHAR(255)Address line 2
cityVARCHAR(100)City
stateVARCHAR(100)State
postal_codeVARCHAR(20)Postal code
countryVARCHAR(100)DEFAULT ‘Australia’Country
websiteVARCHAR(255)Website URL
industryVARCHAR(100)Industry type
statusVARCHAR(20)DEFAULT ‘ACTIVE’Company status
subscription_tierVARCHAR(50)Subscription tier
subscription_start_dateDATESubscription start
subscription_end_dateDATESubscription end
is_customerBOOLEANDEFAULT FALSEIs customer flag
is_transport_companyBOOLEANDEFAULT TRUEIs transport company flag
primary_colorVARCHAR(7)Brand primary color
secondary_colorVARCHAR(7)Brand secondary color
logo_pathVARCHAR(500)Logo file path
enabled_modulesJSONBEnabled modules config
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_companies_status, idx_companies_tenant_id, idx_companies_company_code


User authentication and management.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
uuidUUIDUNIQUEUnique identifier
company_idINTEGERFK -> companies.id, ON DELETE CASCADECompany reference
usernameVARCHAR(50)UNIQUE, NOT NULLUsername
emailVARCHAR(255)UNIQUE, NOT NULLEmail address
password_hashVARCHAR(255)Hashed password
first_nameVARCHAR(100)First name
last_nameVARCHAR(100)Last name
full_nameVARCHAR(200)Full name
phoneVARCHAR(50)Phone number
mobileVARCHAR(50)Mobile number
roleVARCHAR(50)User role
permissionsTEXT[]Permission list
is_activeBOOLEANDEFAULT TRUEActive status
is_verifiedBOOLEANDEFAULT FALSEEmail verified
is_super_adminBOOLEANDEFAULT FALSESuper admin flag
email_verification_tokenVARCHAR(255)Email verification token
password_reset_tokenVARCHAR(255)Password reset token
password_reset_expiresTIMESTAMPToken expiry
last_loginTIMESTAMPLast login time
last_login_ipVARCHAR(45)Last login IP
login_countINTEGERDEFAULT 0Total logins
customer_codeVARCHAR(50)Customer portal code
customer_typeVARCHAR(50)Customer type
credit_limitDECIMAL(15,2)Credit limit
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_users_company_id, idx_users_email, idx_users_username, idx_users_role, idx_users_is_active, idx_users_customer_code


Customer account management.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
uuidUUIDUNIQUEUnique identifier
company_idINTEGERFK -> companies.idCompany reference
nameVARCHAR(255)NOT NULLCustomer name
contact_nameVARCHAR(200)Primary contact
emailVARCHAR(255)Email address
phoneVARCHAR(50)Phone number
addressVARCHAR(500)Address
cityVARCHAR(100)City
stateVARCHAR(100)State
postcodeVARCHAR(20)Postcode
countryVARCHAR(100)DEFAULT ‘Australia’Country
suburbVARCHAR(100)Suburb
account_numberVARCHAR(50)UNIQUEAccount number
account_typeVARCHAR(50)Account type
statusVARCHAR(20)DEFAULT ‘ACTIVE’Status
abnVARCHAR(20)ABN
account_managerVARCHAR(200)Account manager
payment_termsVARCHAR(50)Payment terms
payment_methodVARCHAR(50)Payment method
credit_limitDECIMAL(15,2)Credit limit
tax_numberVARCHAR(50)Tax number
tax_exemptBOOLEANDEFAULT FALSETax exempt flag
ops_contact_nameVARCHAR(200)Operations contact name
ops_contact_emailVARCHAR(255)Operations contact email
ops_contact_phoneVARCHAR(50)Operations contact phone
ops_contact_positionVARCHAR(100)Operations contact position
accounts_contact_nameVARCHAR(200)Accounts contact name
accounts_contact_emailVARCHAR(255)Accounts contact email
accounts_contact_phoneVARCHAR(50)Accounts contact phone
accounts_contact_positionVARCHAR(100)Accounts contact position
additional_contact_nameVARCHAR(200)Additional contact name
additional_contact_emailVARCHAR(255)Additional contact email
additional_contact_phoneVARCHAR(50)Additional contact phone
additional_contact_positionVARCHAR(100)Additional contact position
additional_contact_typeVARCHAR(50)Additional contact type
is_activeBOOLEANDEFAULT TRUEActive flag
activeBOOLEANDEFAULT TRUEActive flag (legacy)
notesTEXTNotes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_customers_company_id, idx_customers_status, idx_customers_is_active, idx_customers_active, idx_customers_account_number, idx_customers_name


Multiple addresses per customer.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
customer_idINTEGERFK -> customers.id, ON DELETE CASCADECustomer reference
address_typeVARCHAR(50)pickup, delivery, billing, head_office
company_nameVARCHAR(255)Company name at address
site_nameVARCHAR(255)Site name
contact_nameVARCHAR(200)Contact name
phoneVARCHAR(50)Phone
emailVARCHAR(255)Email
address_line1VARCHAR(255)NOT NULLAddress line 1
address_line2VARCHAR(255)Address line 2
suburbVARCHAR(100)Suburb
cityVARCHAR(100)City
stateVARCHAR(100)State
postcodeVARCHAR(20)Postcode
countryVARCHAR(100)DEFAULT ‘Australia’Country
is_defaultBOOLEANDEFAULT FALSEDefault address flag
is_residentialBOOLEANDEFAULT FALSEResidential flag
access_instructionsTEXTAccess instructions
delivery_instructionsTEXTDelivery instructions
pickup_instructionsTEXTPickup instructions
notesTEXTNotes
operating_hoursJSONBOperating hours
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_customer_addresses_customer_id, idx_customer_addresses_type, idx_customer_addresses_default, idx_customer_addresses_postcode, idx_customer_addresses_suburb


Reusable site contact information.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
site_nameVARCHAR(255)Site name
contact_personVARCHAR(255)Contact person
phone_numberVARCHAR(50)Phone number
emailVARCHAR(255)Email
address_line1VARCHAR(255)Address line 1
address_line2VARCHAR(255)Address line 2
suburbVARCHAR(100)Suburb
stateVARCHAR(100)State
postcodeVARCHAR(20)Postcode
notesTEXTNotes
usage_countINTEGERDEFAULT 0Usage count
created_byINTEGERUser ID who created
customer_idINTEGEROptional customer link
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_site_contacts_address, idx_site_contacts_phone, idx_site_contacts_email, idx_site_contacts_customer, idx_site_contacts_usage


Australian states and territories.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
codeVARCHAR(3)UNIQUEState code (NSW, VIC, etc.)
nameVARCHAR(100)State name
abbreviationVARCHAR(10)Abbreviation
countryVARCHAR(100)DEFAULT ‘Australia’Country
is_activeBOOLEANDEFAULT TRUEActive flag

Default Data: NSW, VIC, QLD, SA, WA, TAS, NT, ACT


Countries reference data.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
codeVARCHAR(3)UNIQUECountry code
nameVARCHAR(100)Country name
currencyVARCHAR(3)Currency code
is_activeBOOLEANDEFAULT TRUEActive flag

Default Data: AU, NZ, US, CA, GB, CN, JP, KR, SG, MY, TH, IN, ID, PH, VN, FR, DE, IT, ES, NL


Geographic service zones.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
nameVARCHAR(255)NOT NULLZone name
short_nameVARCHAR(50)Short name
codeVARCHAR(10)UNIQUEZone code
zone_typeVARCHAR(50)Metro, Regional, Remote
stateVARCHAR(100)State
countryVARCHAR(100)DEFAULT ‘Australia’Country
boundary_geojsonTEXTGeoJSON boundary
center_latDECIMAL(10,6)Center latitude
center_lngDECIMAL(10,6)Center longitude
service_flagVARCHAR(50)Full Service, Limited Service, No Service
coverage_radius_kmDECIMAL(10,2)Coverage radius
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_zones_company_id, idx_zones_code, idx_zones_is_active, idx_zones_zone_type


Suburbs and localities within zones.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
zone_idINTEGERFK -> zones.id, ON DELETE CASCADEZone reference
nameVARCHAR(255)Name
suburb_nameVARCHAR(255)Suburb name
cityVARCHAR(100)City
postcodeVARCHAR(20)Postcode
state_codeVARCHAR(10)State code
latitudeDECIMAL(10,6)Latitude
longitudeDECIMAL(10,6)Longitude
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_zone_suburbs_zone_id, idx_zone_suburbs_postcode, idx_zone_suburbs_state_code


Service level definitions.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
nameVARCHAR(100)NOT NULLService level name
descriptionTEXTDescription
priorityINTEGERPriority (lower = higher)
base_cost_multiplierDECIMAL(8,4)DEFAULT 1.0Cost multiplier
transit_time_multiplierDECIMAL(8,4)DEFAULT 1.0Transit time multiplier
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_service_levels_company_id, idx_service_levels_is_active


Freight rate structures.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
customer_idINTEGERFK -> customers.idCustomer reference
nameVARCHAR(255)NOT NULLRate card name
rate_typeVARCHAR(50)NOT NULLquantity, time, flat_rate, weight
descriptionTEXTDescription
effective_dateDATEEffective date
expiry_dateDATEExpiry date
is_activeBOOLEANDEFAULT TRUEActive flag
created_byINTEGERCreated by user ID
updated_byVARCHAR(50)Updated by user
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_rate_cards_customer_id, idx_rate_cards_is_active, idx_rate_cards_effective_date


Individual rates within rate cards.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
rate_card_idINTEGERFK -> rate_cards.id, ON DELETE CASCADERate card reference
origin_zone_idINTEGERFK -> zones.idOrigin zone (nullable)
destination_zone_idINTEGERFK -> zones.idDestination zone (nullable)
service_level_idINTEGERFK -> service_levels.idService level reference
rate_per_kgDECIMAL(10,4)Rate per kilogram
rate_per_palletDECIMAL(10,2)Rate per pallet
rate_per_cubic_meterDECIMAL(10,2)Rate per cubic meter
flat_rateDECIMAL(10,2)Flat rate
hourly_rateDECIMAL(10,2)Hourly rate
minimum_chargeDECIMAL(10,2)Minimum charge
minimum_weight_kgDECIMAL(10,2)Minimum weight
minimum_palletsINTEGERMinimum pallets
transit_time_hoursINTEGERTransit time in hours
charging_typeVARCHAR(50)per_kg, per_pallet, per_cubic_meter, flat_rate
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_rate_entries_rate_card_id, idx_rate_entries_origin_zone, idx_rate_entries_destination_zone, idx_rate_entries_service_level Composite Index: idx_rate_entries_route_service (origin_zone_id, destination_zone_id, service_level_id WHERE is_active = TRUE)


Global surcharge definitions.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
nameVARCHAR(255)NOT NULLSurcharge name
typeVARCHAR(50)NOT NULLFIXED, PERCENTAGE, PER_KG, PER_PALLET
descriptionTEXTDescription
amountDECIMAL(10,2)Fixed amount
percentageDECIMAL(5,2)Percentage value
applies_toVARCHAR(50)ALL, METRO, REGIONAL, REMOTE
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_surcharges_company_id, idx_surcharges_is_active, idx_surcharges_type


Customer-specific surcharge adjustments.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
customer_idINTEGERFK -> customers.id, ON DELETE CASCADECustomer reference
surcharge_idINTEGERFK -> surcharges.id, ON DELETE CASCADESurcharge reference
is_enabledBOOLEANDEFAULT TRUEEnabled flag
adjustment_typeVARCHAR(20)none, override, discount, markup
adjustment_valueDECIMAL(10,2)Adjustment value
adjustment_methodVARCHAR(20)percentage, fixed
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_customer_surcharges_customer_id, idx_customer_surcharges_surcharge_id


Transport bookings.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
customer_idINTEGERFK -> customers.idCustomer reference
booking_numberVARCHAR(50)UNIQUEBooking number
booking_referenceVARCHAR(100)Reference
service_level_idINTEGERFK -> service_levels.idService level
job_typeVARCHAR(50)ltl, ftl, hourly_hire, linehaul
pickup_companyVARCHAR(255)Pickup company
pickup_contactVARCHAR(200)Pickup contact
pickup_phoneVARCHAR(50)Pickup phone
pickup_emailVARCHAR(255)Pickup email
pickup_addressVARCHAR(500)Pickup address
pickup_suburbVARCHAR(100)Pickup suburb
pickup_stateVARCHAR(100)Pickup state
pickup_postcodeVARCHAR(20)Pickup postcode
pickup_dateDATEPickup date
pickup_timeTIMEPickup time
pickup_instructionsTEXTPickup instructions
delivery_companyVARCHAR(255)Delivery company
delivery_contactVARCHAR(200)Delivery contact
delivery_phoneVARCHAR(50)Delivery phone
delivery_emailVARCHAR(255)Delivery email
delivery_addressVARCHAR(500)Delivery address
delivery_suburbVARCHAR(100)Delivery suburb
delivery_stateVARCHAR(100)Delivery state
delivery_postcodeVARCHAR(20)Delivery postcode
delivery_dateDATEDelivery date
delivery_timeTIMEDelivery time
delivery_instructionsTEXTDelivery instructions
freight_descriptionTEXTFreight description
weight_kgDECIMAL(10,2)Weight in kg
cubic_weight_kgDECIMAL(10,2)Cubic weight
chargeable_weight_kgDECIMAL(10,2)Chargeable weight
volume_cubic_metersDECIMAL(10,4)Volume
pallet_countINTEGERPallet count
pallet_typeVARCHAR(50)Pallet type
pieces_countINTEGERPieces count
is_dangerous_goodsBOOLEANDEFAULT FALSEDG flag
is_fragileBOOLEANDEFAULT FALSEFragile flag
is_perishableBOOLEANDEFAULT FALSEPerishable flag
requires_tailgateBOOLEANDEFAULT FALSETailgate required
requires_appointmentBOOLEANDEFAULT FALSEAppointment required
base_rateDECIMAL(10,2)Base rate
surcharges_totalDECIMAL(10,2)Surcharges total
total_amountDECIMAL(10,2)Total amount
statusVARCHAR(50)PENDING, CONFIRMED, DISPATCHED, DELIVERED, CANCELLED
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_bookings_company_id, idx_bookings_customer_id, idx_bookings_booking_number, idx_bookings_status, idx_bookings_pickup_date, idx_bookings_delivery_date Composite Index: idx_bookings_customer_status_date (customer_id, status, pickup_date DESC)


Transport quotes.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
customer_idINTEGERFK -> customers.idCustomer reference
quote_numberVARCHAR(50)UNIQUEQuote number
quote_referenceVARCHAR(100)Reference
service_level_idINTEGERFK -> service_levels.idService level
origin_suburbVARCHAR(100)Origin suburb
origin_stateVARCHAR(100)Origin state
origin_postcodeVARCHAR(20)Origin postcode
destination_suburbVARCHAR(100)Destination suburb
destination_stateVARCHAR(100)Destination state
destination_postcodeVARCHAR(20)Destination postcode
freight_typeVARCHAR(50)Freight type
weight_kgDECIMAL(10,2)Weight
volume_cubic_metersDECIMAL(10,4)Volume
pallet_countINTEGERPallet count
base_rateDECIMAL(10,2)Base rate
surcharges_totalDECIMAL(10,2)Surcharges
total_amountDECIMAL(10,2)Total
valid_untilDATEValidity date
statusVARCHAR(50)PENDING, SENT, ACCEPTED, DECLINED, EXPIRED
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_quotes_company_id, idx_quotes_customer_id, idx_quotes_quote_number, idx_quotes_status, idx_quotes_valid_until


Streamlined unified quoting system.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
customer_idINTEGERFK -> customers.idCustomer reference
quote_numberVARCHAR(20)UNIQUEQuote number
customer_nameVARCHAR(255)Customer name
origin_suburbVARCHAR(100)NOT NULLOrigin suburb
origin_stateVARCHAR(100)Origin state
origin_postcodeVARCHAR(20)Origin postcode
origin_addressVARCHAR(500)Origin address
origin_companyVARCHAR(255)Origin company
origin_contactVARCHAR(200)Origin contact
origin_phoneVARCHAR(50)Origin phone
origin_emailVARCHAR(255)Origin email
origin_tailgateBOOLEANDEFAULT FALSEOrigin tailgate
dest_suburbVARCHAR(100)NOT NULLDestination suburb
dest_stateVARCHAR(100)Destination state
dest_postcodeVARCHAR(20)Destination postcode
dest_addressVARCHAR(500)Destination address
dest_companyVARCHAR(255)Destination company
dest_contactVARCHAR(200)Destination contact
dest_phoneVARCHAR(50)Destination phone
dest_emailVARCHAR(255)Destination email
dest_tailgateBOOLEANDEFAULT FALSEDestination tailgate
freight_typeVARCHAR(50)DEFAULT ‘per_kg’Freight type
service_levelVARCHAR(50)Service level
weightDECIMAL(10,2)NOT NULLWeight
volume_weightDECIMAL(10,2)Volume weight
chargeable_weightDECIMAL(10,2)Chargeable weight
volumeDECIMAL(10,4)Volume
pallet_countINTEGERPallet count
pieces_countINTEGERPieces count
base_rateDECIMAL(10,2)Base rate
fuel_surchargeDECIMAL(10,2)Fuel surcharge
other_surchargesDECIMAL(10,2)Other surcharges
total_amountDECIMAL(10,2)Total amount
reference_numberVARCHAR(100)Reference
descriptionTEXTDescription
special_instructionsTEXTSpecial instructions
statusVARCHAR(50)DEFAULT ‘PENDING’Status
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_unified_quotes_company_id, idx_unified_quotes_customer_id, idx_unified_quotes_quote_number, idx_unified_quotes_status


Base asset model.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
asset_codeVARCHAR(20)UNIQUEAsset code
nameVARCHAR(100)NOT NULLAsset name
descriptionTEXTDescription
asset_typeVARCHAR(50)NOT NULLAsset type
statusVARCHAR(20)DEFAULT ‘ACTIVE’Status
purchase_dateDATEPurchase date
purchase_costDECIMAL(15,2)Purchase cost
current_valueDECIMAL(15,2)Current value
expected_lifetimeINTEGERLifetime in months
manufacturerVARCHAR(100)Manufacturer
modelVARCHAR(100)Model
serial_numberVARCHAR(100)Serial number
yearINTEGERYear
notesTEXTNotes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_assets_asset_code, idx_assets_asset_type, idx_assets_status


Fleet management and organization.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
company_idINTEGERFK -> companies.idCompany reference
nameVARCHAR(100)NOT NULLFleet name
descriptionTEXTDescription
fleet_manager_idINTEGERFK -> users.idFleet manager
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_fleets_company_id, idx_fleets_fleet_manager_id, idx_fleets_is_active


Vehicle asset management.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
registrationVARCHAR(20)UNIQUERegistration number
makeVARCHAR(100)Make
modelVARCHAR(100)Model
yearINTEGERYear
fleet_idINTEGERFK -> fleets.idFleet reference
vehicle_typeVARCHAR(30)NOT NULLVehicle type
capacity_weightDECIMAL(10,2)Weight capacity (kg)
capacity_volumeDECIMAL(10,2)Volume capacity (m³)
capacity_palletsINTEGERPallet capacity
statusVARCHAR(20)DEFAULT ‘AVAILABLE’Status
engine_numberVARCHAR(50)Engine number
chassis_numberVARCHAR(50)Chassis number
fuel_typeVARCHAR(30)Fuel type
transmissionVARCHAR(30)Transmission type
current_latDECIMAL(10,6)Current latitude
current_lngDECIMAL(10,6)Current longitude
location_updated_atTIMESTAMPLocation update time
odometerINTEGERCurrent odometer
insurance_expiryDATEInsurance expiry
registration_expiryDATERegistration expiry
roadworthy_expiryDATERoadworthy expiry
purchase_priceDECIMAL(15,2)Purchase price
current_valueDECIMAL(15,2)Current value
depreciation_rateDECIMAL(5,2)Depreciation rate
last_service_dateDATELast service date
last_service_odometerINTEGERLast service odometer
next_service_due_dateDATENext service date
next_service_due_odometerINTEGERNext service odometer
is_activeBOOLEANDEFAULT TRUEActive flag
notesTEXTNotes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_vehicles_registration, idx_vehicles_fleet_id, idx_vehicles_status, idx_vehicles_vehicle_type, idx_vehicles_is_active


Vehicle maintenance and repair history.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
vehicle_idINTEGERFK -> vehicles.id, ON DELETE CASCADEVehicle reference
maintenance_typeVARCHAR(50)Service, Repair, Inspection
descriptionTEXTNOT NULLDescription
maintenance_dateDATEMaintenance date
odometer_readingINTEGEROdometer reading
service_providerVARCHAR(200)Service provider
technician_nameVARCHAR(200)Technician
parts_costDECIMAL(10,2)Parts cost
labor_costDECIMAL(10,2)Labor cost
total_costDECIMAL(10,2)Total cost
statusVARCHAR(20)SCHEDULED, IN_PROGRESS, COMPLETED, CANCELLED
priorityVARCHAR(20)LOW, MEDIUM, HIGH, URGENT
notesTEXTNotes
next_service_dateDATENext service date
next_service_odometerINTEGERNext service odometer
warranty_expiryDATEWarranty expiry
created_byINTEGERFK -> users.idCreated by
updated_byINTEGERFK -> users.idUpdated by
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_maintenance_records_vehicle_id, idx_maintenance_records_date, idx_maintenance_records_type, idx_maintenance_records_status, idx_maintenance_records_created_by


Individual parts and items in maintenance records.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
maintenance_record_idINTEGERFK -> maintenance_records.id, ON DELETE CASCADERecord reference
item_nameVARCHAR(200)NOT NULLItem name
item_descriptionTEXTDescription
part_numberVARCHAR(50)Part number
quantityINTEGERDEFAULT 1Quantity
unit_costDECIMAL(10,2)Unit cost
total_costDECIMAL(10,2)Total cost
supplierVARCHAR(200)Supplier
warranty_periodINTEGERWarranty (months)
notesTEXTNotes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_maintenance_items_record_id


Safety and compliance inspections.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
vehicle_idINTEGERFK -> vehicles.id, ON DELETE CASCADEVehicle reference
inspection_typeVARCHAR(50)Pre-trip, Daily, Weekly, Annual
inspection_dateDATENOT NULLInspection date
inspector_idINTEGERFK -> users.idInspector
inspector_nameVARCHAR(200)Inspector name
overall_resultVARCHAR(20)PASS, FAIL, CONDITIONAL
odometer_readingINTEGEROdometer reading
checklist_itemsJSONBChecklist items
defects_foundTEXTDefects found
recommendationsTEXTRecommendations
requires_immediate_attentionBOOLEANDEFAULT FALSEImmediate attention flag
next_inspection_dueDATENext inspection date
statusVARCHAR(20)DEFAULT ‘COMPLETED’Status
created_byINTEGERFK -> users.idCreated by
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_vehicle_inspections_vehicle_id, idx_vehicle_inspections_date, idx_vehicle_inspections_type, idx_vehicle_inspections_result


Fuel consumption and efficiency tracking.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
vehicle_idINTEGERFK -> vehicles.id, ON DELETE CASCADEVehicle reference
fuel_dateDATENOT NULLFuel date
fuel_typeVARCHAR(30)Fuel type
quantity_litersDECIMAL(10,2)Quantity (liters)
cost_per_literDECIMAL(6,3)Cost per liter
total_costDECIMAL(10,2)Total cost
fuel_stationVARCHAR(200)Fuel station
locationVARCHAR(200)Location
odometer_readingINTEGEROdometer reading
receipt_numberVARCHAR(50)Receipt number
payment_methodVARCHAR(50)Payment method
driver_idINTEGERFK -> users.idDriver
driver_nameVARCHAR(200)Driver name
distance_since_last_fillDECIMAL(10,2)Distance since last fill
fuel_efficiency_kmplDECIMAL(6,2)Fuel efficiency
notesTEXTNotes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_fuel_records_vehicle_id, idx_fuel_records_date, idx_fuel_records_driver_id


Real-time GPS tracking for assets.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
asset_typeVARCHAR(20)VEHICLE, TRAILER, CONTAINER
asset_idINTEGERAsset ID
latitudeDECIMAL(10,6)Latitude
longitudeDECIMAL(10,6)Longitude
accuracy_metersDECIMAL(8,2)GPS accuracy
altitude_metersDECIMAL(10,2)Altitude
heading_degreesDECIMAL(5,2)Heading
speed_kmhDECIMAL(6,2)Speed
tracked_atTIMESTAMPNOT NULLTracking timestamp
engine_statusVARCHAR(10)ON, OFF, IDLE
fuel_level_percentDECIMAL(5,2)Fuel level
battery_level_percentDECIMAL(5,2)Battery level
driver_idINTEGERFK -> users.idDriver
trip_idVARCHAR(50)Trip ID
odometer_readingINTEGEROdometer
device_idVARCHAR(50)Device ID
device_typeVARCHAR(50)Device type
signal_strengthINTEGERSignal strength
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp

Indexes: idx_asset_tracking_asset, idx_asset_tracking_tracked_at, idx_asset_tracking_driver_id, idx_asset_tracking_trip_id


Pallet specifications and dimensions.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
nameVARCHAR(100)NOT NULLPallet name
descriptionTEXTDescription
standard_sizeVARCHAR(20)Standard size (e.g., 1200x1000)
length_mmINTEGERLength (mm)
width_mmINTEGERWidth (mm)
height_mmINTEGERHeight (mm)
max_weight_kgDECIMAL(10,2)Max weight
max_stack_height_mmINTEGERMax stack height
materialVARCHAR(50)Wood, Plastic, Metal
is_activeBOOLEANDEFAULT TRUEActive flag
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_pallet_types_name, idx_pallet_types_is_active


Workflow templates and business process definitions.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
nameVARCHAR(100)NOT NULLWorkflow name
codeVARCHAR(50)UNIQUEWorkflow code
descriptionTEXTDescription
entity_typeVARCHAR(50)Entity type (BOOKING, QUOTE, etc.)
versionVARCHAR(20)DEFAULT ‘1.0.0’Version
initial_stateVARCHAR(50)Initial state
statesJSONBState definitions
transitionsJSONBTransition definitions
workflow_metadataJSONBDEFAULT ’{}‘Metadata
is_activeBOOLEANDEFAULT TRUEActive flag
created_byINTEGERFK -> users.idCreated by
updated_byINTEGERFK -> users.idUpdated by
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_definitions_code, idx_workflow_definitions_entity_type, idx_workflow_definitions_is_active


Active workflow instances.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
reference_numberVARCHAR(50)Reference number
entity_typeVARCHAR(50)Entity type
entity_idINTEGEREntity ID
workflow_definition_idINTEGERFK -> workflow_definitions.idDefinition reference
current_stateVARCHAR(50)Current state
statusVARCHAR(20)ACTIVE, COMPLETED, CANCELLED, ERROR
due_dateDATEDue date
company_idINTEGERFK -> companies.idCompany reference
started_byINTEGERFK -> users.idStarted by
completed_byINTEGERFK -> users.idCompleted by
completed_atTIMESTAMPCompletion time
workflow_dataJSONBDEFAULT ’{}‘Workflow data
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_instances_definition_id, idx_workflow_instances_entity, idx_workflow_instances_status, idx_workflow_instances_current_state, idx_workflow_instances_company_id, idx_workflow_instances_started_by


Workflow state changes history.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
instance_idINTEGERFK -> workflow_instances.id, ON DELETE CASCADEInstance reference
definition_idINTEGERFK -> workflow_definitions.idDefinition reference
from_stateVARCHAR(50)From state
to_stateVARCHAR(50)To state
transition_nameVARCHAR(100)Transition name
user_idINTEGERFK -> users.idUser
user_nameVARCHAR(200)User name
notesTEXTNotes
transition_dataJSONBDEFAULT ’{}‘Transition data
transition_dateTIMESTAMPDEFAULT CURRENT_TIMESTAMPTransition date
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp

Indexes: idx_workflow_transitions_instance_id, idx_workflow_transitions_definition_id, idx_workflow_transitions_states, idx_workflow_transitions_user_id, idx_workflow_transitions_date


Available states within workflow definitions.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
definition_idINTEGERFK -> workflow_definitions.id, ON DELETE CASCADEDefinition reference
state_nameVARCHAR(50)NOT NULLState name
display_nameVARCHAR(100)Display name
descriptionTEXTDescription
state_typeVARCHAR(20)INITIAL, NORMAL, FINAL, ERROR
color_codeVARCHAR(7)Hex color
iconVARCHAR(50)Icon name
is_activeBOOLEANDEFAULT TRUEActive flag
requires_approvalBOOLEANDEFAULT FALSERequires approval
auto_transitionBOOLEANDEFAULT FALSEAuto transition
auto_transition_delayINTEGERDelay in seconds
notify_on_enterBOOLEANDEFAULT FALSENotify on enter
notification_templateVARCHAR(100)Notification template
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_states_definition_id, idx_workflow_states_name, idx_workflow_states_type


Business rules for workflows.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
definition_idINTEGERFK -> workflow_definitions.id, ON DELETE CASCADEDefinition reference
rule_nameVARCHAR(100)Rule name
rule_typeVARCHAR(50)CONDITION, VALIDATION, ACTION
trigger_stateVARCHAR(50)Trigger state
condition_expressionTEXTCondition expression
action_typeVARCHAR(50)Action type
action_configJSONBAction configuration
is_activeBOOLEANDEFAULT TRUEActive flag
priorityINTEGERDEFAULT 0Priority
on_error_actionVARCHAR(20)DEFAULT ‘LOG’LOG, IGNORE, FAIL
created_byINTEGERFK -> users.idCreated by
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_rules_definition_id, idx_workflow_rules_trigger_state, idx_workflow_rules_is_active


Task assignments in workflows.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
instance_idINTEGERFK -> workflow_instances.id, ON DELETE CASCADEInstance reference
state_nameVARCHAR(50)State name
assigned_to_userINTEGERFK -> users.idAssigned user
assigned_to_roleVARCHAR(50)Assigned role
assigned_byINTEGERFK -> users.idAssigned by
assignment_dateTIMESTAMPDEFAULT CURRENT_TIMESTAMPAssignment date
task_nameVARCHAR(200)Task name
task_descriptionTEXTTask description
priorityVARCHAR(20)DEFAULT ‘MEDIUM’LOW, MEDIUM, HIGH, URGENT
due_dateTIMESTAMPDue date
statusVARCHAR(20)DEFAULT ‘PENDING’PENDING, IN_PROGRESS, COMPLETED, CANCELLED
started_atTIMESTAMPStarted time
completed_atTIMESTAMPCompletion time
completion_notesTEXTCompletion notes
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_assignments_instance_id, idx_workflow_assignments_assigned_to, idx_workflow_assignments_status, idx_workflow_assignments_due_date


Detailed workflow event audit log.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
instance_idINTEGERFK -> workflow_instances.id, ON DELETE CASCADEInstance reference
event_typeVARCHAR(50)STATE_CHANGE, ASSIGNMENT, COMMENT, ERROR
event_descriptionTEXTEvent description
old_stateVARCHAR(50)Old state
new_stateVARCHAR(50)New state
user_idINTEGERFK -> users.idUser
user_nameVARCHAR(200)User name
event_dataJSONBEvent data
event_timestampTIMESTAMPDEFAULT CURRENT_TIMESTAMPEvent timestamp
ip_addressVARCHAR(45)IP address
user_agentVARCHAR(500)User agent
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp

Indexes: idx_workflow_history_instance_id, idx_workflow_history_event_type, idx_workflow_history_timestamp, idx_workflow_history_user_id


Notifications triggered by workflow events.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
instance_idINTEGERFK -> workflow_instances.id, ON DELETE CASCADEInstance reference
notification_typeVARCHAR(50)EMAIL, SMS, PUSH, WEBHOOK
recipient_typeVARCHAR(20)USER, ROLE, EMAIL
recipient_identifierVARCHAR(255)Recipient identifier
subjectVARCHAR(500)Subject
messageTEXTMessage
message_dataJSONBMessage data
statusVARCHAR(20)DEFAULT ‘PENDING’PENDING, SENT, FAILED
sent_atTIMESTAMPSent time
error_messageTEXTError message
retry_countINTEGERDEFAULT 0Retry count
max_retriesINTEGERDEFAULT 3Max retries
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp
updated_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPUpdated timestamp

Indexes: idx_workflow_notifications_instance_id, idx_workflow_notifications_status, idx_workflow_notifications_recipient


Performance metrics and analytics.

ColumnTypeConstraintsDescription
idSERIALPKPrimary key
definition_idINTEGERFK -> workflow_definitions.idDefinition reference
instance_idINTEGERFK -> workflow_instances.idInstance reference
metric_nameVARCHAR(100)Metric name
metric_typeVARCHAR(50)DURATION, COUNT, COST
metric_valueDECIMAL(15,4)Metric value
metric_unitVARCHAR(20)Metric unit
state_nameVARCHAR(50)State name
user_idINTEGERFK -> users.idUser
measurement_dateDATEMeasurement date
metric_dataJSONBMetric data
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPCreated timestamp

Indexes: idx_workflow_metrics_definition_id, idx_workflow_metrics_instance_id, idx_workflow_metrics_name, idx_workflow_metrics_date


(Tables include: ltl_bookings, ltl_pickup_jobs, consolidation_manifests, linehaul_dispatches, delivery_manifests, driver_manifests, manifest_shipments, dispatch_centers, dispatch_jobs, job_status_updates, pallet_tracking)

See the Operations diagram above for relationships. Each table follows the same pattern with primary keys, foreign keys, indexes, and audit timestamps.


(Tables include: compliance_categories, accreditations, staff_certifications, safety_incidents, training_programs, training_records, compliance_audit_trails, regulatory_inspections, compliance_checklists, checklist_assessments)

See the Compliance diagram above for relationships.


(Tables include: user_profiles, certifications, schedules, time_records, leave_requests, leave_balances, performance_reviews, disciplinary_actions)

See the Staff Management diagram above for relationships.


tenants → tenant_settings (1:1)
tenants → companies (1:N)
companies → users (1:N)
companies → customers (1:N)
users → user_profiles (1:1)
user_profiles → certifications (1:N)
user_profiles → schedules (1:N)
user_profiles → time_records (1:N)
user_profiles → leave_requests (1:N)
user_profiles → performance_reviews (1:N)
customers → customer_addresses (1:N)
customers → rate_cards (1:N)
rate_cards → rate_entries (1:N)
rate_entries → zones (N:1 for origin/destination)
rate_entries → service_levels (N:1)
customers → bookings (1:N)
customers → quotes (1:N)
customers → ltl_bookings (1:N)
ltl_bookings → ltl_pickup_jobs (N:1)
ltl_bookings → consolidation_manifests (N:1)
consolidation_manifests → linehaul_dispatches (N:1)
ltl_bookings → delivery_manifests (N:1)
companies → fleets (1:N)
fleets → vehicles (1:N)
vehicles → maintenance_records (1:N)
vehicles → vehicle_inspections (1:N)
vehicles → fuel_records (1:N)
workflow_definitions → workflow_instances (1:N)
workflow_definitions → workflow_states (1:N)
workflow_definitions → workflow_rules (1:N)
workflow_instances → workflow_transitions (1:N)
workflow_instances → workflow_assignments (1:N)
workflow_instances → workflow_history (1:N)

TableIndex NameColumnsPurpose
rate_entriesidx_rate_entries_route_serviceorigin_zone_id, destination_zone_id, service_level_idRate lookups
bookingsidx_bookings_customer_status_datecustomer_id, status, pickup_date DESCCustomer booking queries
zone_suburbsidx_zone_suburbs_postcode_statepostcode, state_codePostcode lookups
  • idx_customers_active WHERE is_active = TRUE
  • idx_zones_active WHERE is_active = TRUE
  • idx_service_levels_active WHERE is_active = TRUE
  • idx_rate_cards_active WHERE is_active = TRUE
  • idx_customers_name_search ON customers (name)
  • idx_zones_name_search ON zones (name)
  • idx_zone_suburbs_name_search ON zone_suburbs (suburb_name)
TableConstraintExpression
rate_entrieschk_different_zonesorigin_zone_id != destination_zone_id
bookingschk_delivery_after_pickupdelivery_date >= pickup_date
rate_entrieschk_positive_ratesAll rate columns > 0

CodeName
NSWNew South Wales
VICVictoria
QLDQueensland
SASouth Australia
WAWestern Australia
TASTasmania
NTNorthern Territory
ACTAustralian Capital Territory

Australia, New Zealand, USA, Canada, UK, China, Japan, South Korea, Singapore, Malaysia, Thailand, India, Indonesia, Philippines, Vietnam, France, Germany, Italy, Spain, Netherlands

Booking Status

  • PENDING, CONFIRMED, DISPATCHED, IN_TRANSIT, DELIVERED, CANCELLED

Quote Status

  • PENDING, SENT, ACCEPTED, DECLINED, EXPIRED

Workflow Status

  • ACTIVE, COMPLETED, CANCELLED, ERROR

Vehicle Status

  • AVAILABLE, IN_USE, MAINTENANCE, OUT_OF_SERVICE, RETIRED

Leave Status

  • PENDING, APPROVED, REJECTED, CANCELLED

All tables include:

  • created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  • updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

An automatic trigger updates updated_at on every row modification:

CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER update_[table]_updated_at
BEFORE UPDATE ON [table]
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();

Most tables also include:

  • created_by (VARCHAR or INTEGER FK -> users.id)
  • updated_by (VARCHAR or INTEGER FK -> users.id)

CategoryCount
Total Tables69+
Total Indexes100+
Total Foreign Keys150+
Check Constraints5+
Audit Triggers69+
Database Views2

  • Schema SQL files: exports/01_core_schema.sql through exports/07_staff_management_schema.sql
  • SQLAlchemy models: models/ directory
  • Migration files: migrations/ directory

Last updated: December 2024