Database · MySQL 8.0 · Aurora-compatible
Schema
The database behind the Availability & Capacity Service and the Delivery Scheduler. Generated from the migration file, so every column shown is one the database actually creates.
Real samples come from the prod_delivery_scheduler export of 16/10/2026, whose IDs and figures come from NetSuite and the WH picking schedule sheet. They follow one truck-day: Bris 01 in Bris R1 (Sunshine Coast) on Wed 7 Oct 2026, 2.2914 of 14 m³ and 5 of 12 stops committed. Tables with no real rows yet use labelled examples. No customer details appear here.
PK primary key
FK links to another table
UK unique
required / optional
Rule 5 enforced by the database
SO123456 example
How the tables connect
Every column except the timestamps. Types, rules and samples are in the tables below. Scrolls sideways on a small screen.
erDiagram
depot {
char code PK
varchar name
varchar time_zone
}
region {
bigint id PK
varchar code UK
varchar name UK
char depot_code FK
varchar external_id UK
}
postcode {
char postcode PK
bigint region_id FK
}
truck {
bigint id PK
varchar name UK
char depot_code FK
varchar kind
decimal max_cbm
boolean active
}
courier {
bigint id PK
varchar courier_code UK
varchar name UK
boolean active
}
courier_shipmethod {
bigint id PK
bigint courier_id FK
varchar ns_account UK
varchar netsuite_internal_id UK
}
netsuite_mapping {
bigint id PK
varchar ns_account UK
varchar category UK
varchar internal_id UK
varchar name
}
availability_pattern {
bigint id PK
bigint truck_id FK
bigint region_id FK
tinyint weekday
varchar schedule_role
decimal cbm_capacity
int max_stops
int buffer_days
date valid_from
date valid_to
}
run {
bigint id PK
bigint truck_id FK,UK
date run_date UK
varchar schedule_role
varchar status
varchar status_reason
varchar created_by
varchar updated_by
}
run_region {
bigint id PK
bigint run_id FK,UK
bigint region_id FK,UK
decimal cbm_capacity
int max_stops
int buffer_days
decimal cbm_committed
int stops_committed
}
courier_day {
bigint id PK
bigint courier_id FK,UK
date day UK
varchar status
varchar status_reason
int buffer_days
}
reservation {
bigint id PK
varchar idempotency_key UK
varchar consumer
varchar source
varchar order_ref
bigint run_region_id FK
varchar leg
varchar group_ref
varchar status
datetime held_until
decimal cbm
int stops
char postcode
date delivery_date
date ship_date
varchar truck_name
varchar created_by
}
adhoc_entry {
bigint id PK
varchar order_ref
varchar reason
bigint region_id FK
varchar status
varchar created_by
varchar updated_by
}
adhoc_item {
bigint id PK
bigint adhoc_entry_id FK
varchar sku
int qty
decimal cbm
}
event {
bigint id PK
datetime occurred_at
varchar actor
varchar kind
varchar subject_type
varchar subject_id
json before
json after
varchar reason
varchar request_id
}
availability_check {
bigint id PK
datetime checked_at
varchar consumer
varchar request_id
varchar order_ref
varchar postcode
decimal order_cbm
date requested_date
int dates_returned
date first_date
varchar outcome
}
region ||--o{ adhoc_entry : "region_id"
adhoc_entry ||--o{ adhoc_item : "adhoc_entry_id"
truck ||--o{ availability_pattern : "truck_id"
region ||--o{ availability_pattern : "region_id"
courier ||--o{ courier_day : "courier_id"
courier ||--o{ courier_shipmethod : "courier_id"
region ||--o{ postcode : "belongs to"
depot ||--o{ region : "served from"
run_region ||--o{ reservation : "takes capacity"
truck ||--o{ run : "drives"
run ||--o{ run_region : "has regions"
region ||--o{ run_region : "region_id"
depot ||--o{ truck : "based at"