Skip to content

VIA Platform Database Schema

Total Tables: 10 ORM: SQLAlchemy Database: PostgreSQL + TimescaleDB

Tables

User (users)

ColumnTypeAttributes
user_idInteger🔑 Primary Key
emailString
password_hashString
nameString
roleString
statusString
company_idInteger
created_atDateTime
updated_atDateTime

RefreshToken (refresh_tokens)

ColumnTypeAttributes
idInteger🔑 Primary Key
tokenString
user_idInteger🔗 Foreign Key
expires_atDateTime
revokedBoolean NOT NULL📝 Default
created_atDateTime

PasswordResetToken (password_reset_tokens)

ColumnTypeAttributes
idInteger🔑 Primary Key
tokenString
user_idInteger🔗 Foreign Key
expires_atDateTime
usedBoolean NOT NULL📝 Default
created_atDateTime

Company (companies)

ColumnTypeAttributes
company_idInteger🔑 Primary Key
nameString
rfcString
statusString
contact_emailString
contact_phoneString
addressString
cityString
stateString
countryString
fleet_sizeString
total_violationsString
compliance_scoreString
created_atDateTime
updated_atDateTime

Truck (trucks)

ColumnTypeAttributes
truck_idInteger🔑 Primary Key
company_idInteger🔗 Foreign Key
registrationString
truck_typeString
statusString
brandString
modelString
yearString
current_driver_idInteger🔗 Foreign Key
current_locationString
capacity_tonsString
gps_statusString
created_atDateTime
updated_atDateTime

Driver (drivers)

ColumnTypeAttributes
driver_idInteger🔑 Primary Key
company_idInteger🔗 Foreign Key
nameString
license_numberString
statusString
phoneString
emailString
total_tripsString
total_violationsString
safety_scoreString
speed_violationsString
created_atDateTime
updated_atDateTime

Terminal (terminals)

ColumnTypeAttributes
terminal_idInteger🔑 Primary Key
nameString
portString
statusString
locationString
cityString
countryString
contact_emailString
contact_phoneString
operating_hoursString
recent_sequencesString
created_atDateTime
updated_atDateTime

Patio (patios)

ColumnTypeAttributes
patio_idInteger🔑 Primary Key
nameString
zoneString
statusString
locationString
cityString
countryString
contact_emailString
contact_phoneString
total_capacityString
available_capacityString
capacity_historyString
created_atDateTime
updated_atDateTime

Convoy (convoys)

ColumnTypeAttributes
convoy_idInteger🔑 Primary Key
convoy_codeString
destination_patio_idInteger🔗 Foreign Key
terminal_idInteger🔗 Foreign Key
sequence_idInteger
leader_truck_idInteger🔗 Foreign Key
truck_countInteger NOT NULL📝 Default
container_countInteger NOT NULL📝 Default
departure_timeDateTime
etaDateTime
actual_departureDateTime
actual_arrivalDateTime
distance_kmFloat
max_speed_kmhInteger📝 Default
travel_time_minFloat
loading_time_minInteger
total_time_minFloat
current_speed_kmhFloat
current_latFloat
current_lngFloat
throttle_activeBoolean NOT NULL📝 Default
statusString
notesText
created_atDateTime
updated_atDateTime

ConvoyTruck (convoy_trucks)

ColumnTypeAttributes
idInteger🔑 Primary Key
convoy_idInteger🔗 Foreign Key
truck_idInteger🔗 Foreign Key
positionInteger NOT NULL📝 Default
is_leaderBoolean NOT NULL📝 Default
driver_idInteger🔗 Foreign Key
container_numbersJSON📝 Default
truck_typeString
sequence_unit_idInteger
statusString
created_atDateTime

Relationships

Foreign key relationships are defined using SQLAlchemy's ForeignKey and relationship().

Common Patterns:

  • One-to-Many: Parent uses relationship() with back_populates
  • Many-to-One: Child uses ForeignKey() column
  • Many-to-Many: Junction table with two ForeignKey columns

Last Updated: 2026-02-28 11:36:05 Auto-generated from SQLAlchemy models Models Location: {models_file.name}

HandyManny Documentation System