Data Schema

Postgres schema & access policies

All core tables, their relationships, and the row-level security rules that gate access per role. 2,372 rows ready for migration.

customers105 rows
iduuidPK
nametext
emailtextunique
phonetext
addresstext
statusenumactive/inactive
created_attimestamptz
vehicles118 rows
iduuidPK
customer_iduuidFK → customers
regotextunique
vintext
maketext
modeltext
yearint
odometerint
work_orders943 rows
iduuidPK
job_numbertextunique
customer_iduuidFK
vehicle_iduuidFK
technician_iduuidFK → users
statusenum
priorityenum
booked_fortimestamptz
totalnumeric(10,2)
invoices927 rows
iduuidPK
numbertextunique
job_iduuidFK → work_orders
customer_iduuidFK
amountnumeric
taxnumeric
totalnumeric
statusenumdraft/sent/paid/overdue
xero_idtextsynced
stock_items238 rows
iduuidPK
skutextunique
nametext
categorytext
supplier_iduuidFK
qtyint
reorder_atint
costnumeric
pricenumeric
suppliers41 rows
iduuidPK
nametext
categorytext
contacttext
emailtext
phonetext

Row-Level Security — what each role can see

Enforced at the database layer via Postgres RLS policies, independent of application code.

RoleSELECTINSERT / UPDATE / DELETE
customerown customers row · own vehicles · own work_orders · own invoicesown customers (profile only)
technicianwork_orders assigned to self · vehicles + customers linked to those jobs · stock_itemsassigned work_orders (status, time, notes)
advisorall customers, vehicles, work_orders, invoices, stockall customers, vehicles, work_orders, invoices
admineverything incl. users, audit_log, supplierseverything (full operational control)
Migration plan. CSV exports from MechanicDesk are mapped 1:1 to the schema above. Identity columns are remapped to UUIDs and historical job→invoice relationships are preserved.