LIFE LOGISTIC Availability & Capacity Service SCHEMA · NOT LIVE
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
  region {
    bigint id PK
    varchar code UK
    varchar name UK
    char depot_code
    varchar external_id UK
  }
  postcode {
    char postcode PK
    bigint region_id FK
  }
  truck {
    bigint id PK
    varchar name UK
    char depot_code
    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
    json cartons
    varchar created_by
    varchar updated_by
  }
  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"
  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"
  run_region ||--o{ reservation : "takes capacity"
  truck ||--o{ run : "drives"
  run ||--o{ run_region : "has regions"
  region ||--o{ run_region : "region_id"

Tables and columns

Compared with Sushil's schema

For reference only — nothing here is used by this service. 11 tables, 99 columns in prod_delivery_scheduler today. Columns: prod_delivery_scheduler export, information_schema columns (16/10/2026). Keys: lifeinteriors/lifeinte-fulfillment@effcd25 packages/db/src/schema.ts (read only). Names and types only. No row data.

SushilThis schemaWhat changedWhich is better, and why
courierscourier + courier_shipmethodShip-method ids move out of a JSON array on runs into their own table, keyed by NetSuite account + id.Ours. Holds Life and ES ids side by side (D18); his has Life ids only.
regionsregion (depot code)Same regions and names. Each region carries its depot code (SYD, MEL, BNE); the time zones live in code.Ours. "Today" is computed per depot (rule 11; Brisbane has no DST).
life_truckstruckAdds depot code, last-mile/linehaul kind and the physical maximum load.Ours. Nothing in his stops a run being typed above what the truck can carry (rule 2, Q29).
postcodespostcodeSame.Equal.
runsavailability_pattern + run + run_region + courier_dayHis run is an undated courier × region × truck row. Ours splits it: the weekly plan, the dated truck-day (one per truck per date), capacity per region within that day, and courier operating days.Ours. His unique (courier, region, truck) cannot stop one truck being booked in three regions on the same day (rule 1).
run_availability_daysrun.status + status_reason · courier_dayAvailable becomes a status with a mandatory reason when not available.Ours. A 0 with no reason cannot tell "suspended" from "nobody filled it in" (rule 4).
run_capacity_daysrun_region.cbm_committed / stops_committed + NetSuite read copiesCommitted load is changed only by one conditional write, checked against capacity in the database, and split by source. NetSuite load is a read copy refreshed every 30 min (D16).Ours. His is recalculated wholesale from a snapshot, with no source split (rule 3) and no committed ≤ capacity check (rule 5).
netsuite_mappingnetsuite_mappingAdds the NetSuite account.Ours, slightly. ES ids can sit beside Life ids.
eventsevent + availability_checkHis logs API traffic and stores every order, names and addresses included, per sync. Ours records decisions (who, before, after, why) and every availability check, with no customer data.Ours. Rules 9 and 10, and no personal data kept per run.
adhoc_entriesadhoc_entry + reservation (source adhoc)Ours keeps order ref, reason, region and status; capacity is taken through a reservation.His, on one point. He stores the delivery address, contact, dates and carton count. Ours has nowhere for the address the driver needs. Gap to decide (where the address lives, given the no-personal-data-in-logs rule).
adhoc_entry_cartonsadhoc_entry.cartonsFolded into the entry as a list (D19): SKU or none, qty, length, width, height, kg and m³ per carton.Equal on content; ours is one table fewer. Cartons are never queried on their own.
—reservationNew: an order's claim on capacity — held, confirmed or released, never deleted, idempotent, interstate legs paired, values snapshotted.Ours. Rules 5–8; nothing in his records who took capacity or lets it be released.

His tables as they connect

Every column except the timestamps.

erDiagram
  couriers {
    bigint id PK
    varchar name UK
    varchar courier_code UK
    tinyint active
  }
  regions {
    bigint id PK
    varchar name UK
    varchar external_id UK
  }
  life_trucks {
    bigint id PK
    varchar name UK
    tinyint active
  }
  postcodes {
    bigint id PK
    varchar postcode UK
    bigint region_id FK
  }
  runs {
    bigint id PK
    bigint courier_id FK
    bigint region_id FK
    bigint truck_id FK
    json netsuite_internal_ids
    decimal cbm_capacity
    int max_delivery_stops
    int buffer_days
    text note
    tinyint active
    enum schedule_role
    enum haul_type
  }
  run_availability_days {
    bigint id PK
    bigint run_id FK
    date date
    tinyint available
    varchar source
  }
  run_capacity_days {
    bigint id PK
    bigint run_id FK
    date date
    decimal committed_cbm
    int committed_qty
    int committed_stops
    varchar source
    timestamp synced_at
  }
  netsuite_mapping {
    bigint id PK
    varchar category
    varchar internal_id
    varchar name
  }
  events {
    bigint id PK
    varchar event_type
    varchar identifier
    json payload
  }
  adhoc_entries {
    bigint id PK
    varchar order_ref
    varchar reason
    varchar customer_name
    varchar phone
    varchar street
    varchar suburb
    varchar postcode
    bigint region_id FK
    int carton_count
    decimal committed_cbm
    decimal weight_kg
    bigint run_id FK
    bigint courier_id FK
    bigint truck_id FK
    date ship_date
    date schedule_delivery_date
    bigint line_haul_run_id FK
    bigint line_haul_truck_id FK
    date line_haul_date
    varchar created_by
    varchar updated_by
    enum status
  }
  adhoc_entry_cartons {
    bigint id PK
    bigint adhoc_entry_id FK
    int position
    decimal length_cm
    decimal width_cm
    decimal height_cm
    decimal weight_kg
    decimal committed_cbm
  }
  regions ||--o{ postcodes : "region_id"
  couriers ||--o{ runs : "courier_id"
  regions ||--o{ runs : "region_id"
  life_trucks ||--o{ runs : "truck_id"
  runs ||--o{ run_availability_days : "run_id"
  runs ||--o{ run_capacity_days : "run_id"
  regions ||--o{ adhoc_entries : "region_id"
  runs ||--o{ adhoc_entries : "run_id"
  couriers ||--o{ adhoc_entries : "courier_id"
  life_trucks ||--o{ adhoc_entries : "truck_id"
  runs ||--o{ adhoc_entries : "line_haul_run_id"
  life_trucks ||--o{ adhoc_entries : "line_haul_truck_id"
  adhoc_entries ||--o{ adhoc_entry_cartons : "adhoc_entry_id"

His tables and columns

Open a table to see its columns.

couriers Life and the third-party couriers.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
namevarchar(255)yes
courier_codevarchar(64)yes
activetinyint(1)yes1
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: name; courier_code

regions Life delivery regions, by the name NetSuite uses.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
namevarchar(255)yes
external_idvarchar(64)no
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: name; external_id

life_trucks Truck and linehaul names. No depot, type or capacity.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
namevarchar(255)yes
activetinyint(1)yes1
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: name

postcodes Postcode → region.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
postcodevarchar(10)yes
region_idbigint unsignedyesFK→ regions
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: postcode

runs One row per courier × region × truck: capacity, max stops, buffer, the NetSuite ship-method ids, ship/delivery-date role and last-mile/linehaul. Not dated.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
courier_idbigint unsignedyesFK→ couriers
region_idbigint unsignednoFK→ regions
truck_idbigint unsignednoFK→ life_trucks
netsuite_internal_idsjsonyes[]
cbm_capacitydecimal(6,2)no
max_delivery_stopsintno
buffer_daysintyes0
notetextno
activetinyint(1)yes1
schedule_roleenum('SHIP_DATE','DELIVERY_DATE')yesSHIP_DATE
haul_typeenum('LAST_MILE','LINE_HAUL')yesLAST_MILE
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: courier_id + region_id + truck_id

run_availability_days Whether a run operates on a date (1/0), synced from the WH picking schedule sheet.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
run_idbigint unsignedyesFK→ runs
datedateyes
availabletinyint(1)yes
sourcevarchar(64)yessheet_sync
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: run_id + date

run_capacity_days Committed m³, quantity and stops per run per date, recalculated from the NetSuite snapshot.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
run_idbigint unsignedyesFK→ runs
datedateyes
committed_cbmdecimal(10,4)yes0.0000
committed_qtyintyes0
committed_stopsintyes0
sourcevarchar(64)yesnetsuite_sync
synced_attimestampyesnow()
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: run_id + date

netsuite_mapping Lookups: Detrack truck numbers, linehaul routes, reason codes.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
categoryvarchar(64)yes
internal_idvarchar(255)yes
namevarchar(255)yes
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: category + internal_id

events API request/response log and one JSON snapshot of every order per sync run.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
event_typevarchar(64)yes
identifiervarchar(255)yes
payloadjsonyes
created_attimestampyesnow()
updated_attimestampyesnow()
adhoc_entries An ad hoc delivery: order ref, reason, customer name, phone, street, postcode, region, run, courier, truck, ship/delivery/linehaul dates, carton count, m³, weight, status.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
order_refvarchar(64)yes
reasonvarchar(200)yes
customer_namevarchar(255)yes
phonevarchar(32)yes
streetvarchar(255)yes
suburbvarchar(128)no
postcodevarchar(10)yes
region_idbigint unsignedyesFK→ regions
carton_countintyes
committed_cbmdecimal(10,4)yes
weight_kgdecimal(8,2)yes
run_idbigint unsignedyesFK→ runs
courier_idbigint unsignedyesFK→ couriers
truck_idbigint unsignednoFK→ life_trucks
ship_datedateno
schedule_delivery_datedateno
line_haul_run_idbigint unsignednoFK→ runs
line_haul_truck_idbigint unsignednoFK→ life_trucks
line_haul_datedateno
created_byvarchar(255)yes
updated_byvarchar(255)yes
created_attimestampyesnow()
updated_attimestampyesnow()
statusenum('ACTIVE','ON_HOLD','CANCELLED')yesACTIVE
adhoc_entry_cartons Each carton of an ad hoc entry: length, width, height, weight and m³.
ColumnTypeRequiredDefaultKeyLinks to
idbigint unsignedyesPK
adhoc_entry_idbigint unsignedyesFK→ adhoc_entries
positionintyes
length_cmdecimal(7,2)yes
width_cmdecimal(7,2)yes
height_cmdecimal(7,2)yes
weight_kgdecimal(8,2)yes
committed_cbmdecimal(10,4)yes
created_attimestampyesnow()
updated_attimestampyesnow()

Unique: adhoc_entry_id + position