idUUID PK
business_nameVARCHAR(200)
slugVARCHAR(100) UNIQUE
phoneVARCHAR(20)
wa_phone_number_idVARCHAR(50)
wa_access_tokenTEXT ENCRYPTED
planENUM(free,pro,scale)
is_activeBOOLEANDEFAULT true
created_atTIMESTAMPTZ
idUUID PK
tenant_idUUID FK → tenants
nameVARCHAR(150)
emailVARCHAR(255) UNIQUE
phoneVARCHAR(20)
password_hashTEXT
roleENUM(owner,staff,viewer)
last_login_atTIMESTAMPTZ
created_atTIMESTAMPTZ
idUUID PK
tenant_idUUID FK
nameVARCHAR(150)
phoneVARCHAR(20)
wa_idVARCHAR(30)WhatsApp ID
emailVARCHAR(255)
birthdayDATE
notesTEXT
total_ordersINT DEFAULT 0
total_spentDECIMAL(12,2)
last_order_atTIMESTAMPTZ
created_atTIMESTAMPTZ
idUUID PK
customer_idUUID FK
tenant_idUUID FK
versionINT DEFAULT 1
is_currentBOOLEAN DEFAULT true
chestDECIMAL(5,2)inches
waistDECIMAL(5,2)
hipDECIMAL(5,2)
shoulderDECIMAL(5,2)
sleeveDECIMAL(5,2)
inseamDECIMAL(5,2)
neckDECIMAL(5,2)
custom_fieldsJSONBflexible
notesTEXT
taken_atTIMESTAMPTZ
idUUID PK
order_refVARCHAR(20)e.g. SEW-0042
tenant_idUUID FK
customer_idUUID FK
measurement_idUUID FK
assigned_toUUID FK → users
style_nameVARCHAR(200)
style_detailsTEXT
fabric_infoTEXT
reference_imagesTEXT[]S3 URLs
priceDECIMAL(12,2)
deposit_amountDECIMAL(12,2)
balance_dueDECIMAL(12,2)GENERATED
current_stageENUM(received,cutting,sewing,fitting,ready,delivered)
deadlineTIMESTAMPTZ
sourceENUM(whatsapp,dashboard,walk_in)
wa_thread_idVARCHAR(50)
notesTEXT
created_atTIMESTAMPTZ
updated_atTIMESTAMPTZ
idUUID PK
order_idUUID FK
tenant_idUUID FK
stageENUM (same as orders)
entered_atTIMESTAMPTZ
exited_atTIMESTAMPTZ
changed_byUUID FK → users
noteTEXT
idUUID PK
order_idUUID FK
tenant_idUUID FK
amountDECIMAL(12,2)
currencyVARCHAR(3) DEFAULT 'NGN'
typeENUM(deposit,balance,full)
providerENUM(paystack,flutterwave)
provider_refVARCHAR(100)
payment_linkTEXT
statusENUM(pending,paid,failed,refunded)
link_sent_atTIMESTAMPTZ
paid_atTIMESTAMPTZ
created_atTIMESTAMPTZ
idUUID PK
tenant_idUUID FK
trigger_typeENUM(customer_inactive,order_ready,unpaid_balance,birthday,upsell,deadline_risk)
is_enabledBOOLEAN DEFAULT true
configJSONBthresholds, delays
message_templateTEXT
last_run_atTIMESTAMPTZ
idUUID PK
tenant_idUUID FK
customer_idUUID FK NULLABLE
order_idUUID FK NULLABLE
wa_message_idVARCHAR(100)
directionENUM(inbound,outbound)
from_numberVARCHAR(20)
bodyTEXT
parsed_dataJSONBAI extracted
is_processedBOOLEAN DEFAULT false
received_atTIMESTAMPTZ