Skip to content

Database Schema

All tables use PostgreSQL via Drizzle ORM. Integer monetary amounts are stored in the smallest currency unit (cents). Timestamps use timestamptz. UUIDs are auto-generated with gen_random_uuid() unless noted.


ColumnTypeConstraints
iduuidPK, default random
typetextNOT NULL
slugtextNOT NULL, UNIQUE
statustextNOT NULL, default 'draft'. Enum: draft, active, archived, discontinued
is_visiblebooleanNOT NULL, default false
metadatajsonbdefault {}
created_attimestamptzNOT NULL, default now()
updated_attimestamptzNOT NULL, default now()
published_attimestamptz

Indexes: type, status, slug.

ColumnTypeConstraints
iduuidPK
entity_iduuidNOT NULL, FK sellable_entities.id ON DELETE CASCADE
localetextNOT NULL, default 'en'
titletextNOT NULL
subtitletext
descriptiontext
rich_descriptionjsonb
seo_titletext
seo_descriptiontext

Index: (entity_id, locale).

ColumnTypeConstraints
iduuidPK
entity_iduuidNOT NULL, FK sellable_entities.id ON DELETE CASCADE
skutextUNIQUE
barcodetext
statustextNOT NULL, default 'active'. Enum: active, discontinued
sort_orderintegerNOT NULL, default 0
metadatajsonbdefault {}
ColumnTypeConstraints
iduuidPK
parent_iduuidFK categories.id ON DELETE SET NULL
slugtextNOT NULL, UNIQUE
sort_orderintegerNOT NULL, default 0
metadatajsonbdefault {}

ColumnTypeConstraints
iduuidPK
nametextNOT NULL
codetextNOT NULL, UNIQUE
addressjsonb
is_activebooleanNOT NULL, default true
priorityintegerNOT NULL, default 0
ColumnTypeConstraints
iduuidPK
entity_iduuidNOT NULL, FK sellable_entities.id ON DELETE CASCADE
variant_iduuidFK variants.id ON DELETE CASCADE
warehouse_iduuidNOT NULL, FK warehouses.id
quantity_on_handintegerNOT NULL, default 0
quantity_reservedintegerNOT NULL, default 0
quantity_incomingintegerNOT NULL, default 0
unit_costinteger
reorder_thresholdinteger
reorder_quantityinteger
versionintegerNOT NULL, default 0. Used for optimistic locking.
last_restocked_attimestamptz

Index: (entity_id, variant_id, warehouse_id).

ColumnTypeConstraints
iduuidPK
entity_iduuidNOT NULL
variant_iduuid
warehouse_iduuidNOT NULL
typetextEnum: receipt, sale, return, adjustment, transfer, reservation, release
quantityintegerNOT NULL
reference_typetext
reference_idtext
reasontext
performed_bytextNOT NULL
performed_attimestamptzNOT NULL, default now()

ColumnTypeConstraints
iduuidPK
customer_iduuid
statustextEnum: active, merged, checked_out, abandoned
currencytextNOT NULL, default 'USD'
secrettext
expires_attimestamptzNOT NULL
ColumnTypeConstraints
iduuidPK
cart_iduuidNOT NULL, FK carts.id ON DELETE CASCADE
entity_iduuidNOT NULL, FK sellable_entities.id
variant_iduuidFK variants.id
quantityintegerNOT NULL, default 1
unit_price_snapshotintegerNOT NULL
currencytextNOT NULL
notestextFree-text notes (POS: “no ice”, “gift wrap”)

ColumnTypeConstraints
iduuidPK
order_numbertextNOT NULL, UNIQUE
customer_iduuid
statustextNOT NULL, default 'pending'
currencytextNOT NULL
subtotalintegerNOT NULL
tax_totalintegerNOT NULL
shipping_totalintegerNOT NULL
discount_totalintegerNOT NULL, default 0
grand_totalintegerNOT NULL
payment_intent_idtextPayment processor transaction ID
payment_method_idtextPayment method used
placed_attimestamptzNOT NULL, default now()
fulfilled_attimestamptz
cancelled_attimestamptz

Order state machine: pending → confirmed → processing → [partially_fulfilled | fulfilled] → refunded. Cancel is allowed from pending, confirmed, processing, partially_fulfilled.

ColumnTypeConstraints
iduuidPK
order_iduuidNOT NULL, FK orders.id ON DELETE CASCADE
entity_iduuidNOT NULL
entity_typetextNOT NULL
variant_iduuid
skutext
titletextNOT NULL
quantityintegerNOT NULL
unit_priceintegerNOT NULL
total_priceintegerNOT NULL
tax_amountintegerNOT NULL, default 0
discount_amountintegerNOT NULL, default 0
fulfillment_statustextNOT NULL, default 'unfulfilled'
ColumnTypeConstraints
iduuidPK
order_iduuidNOT NULL, FK orders.id ON DELETE CASCADE
from_statustextNOT NULL
to_statustextNOT NULL
reasontext
changed_bytextNOT NULL
changed_attimestamptzNOT NULL

ColumnTypeConstraints
iduuidPK
user_idtextNOT NULL, UNIQUE
emailtextUNIQUE
phonetext
first_nametext
last_nametext
metadatajsonbdefault {}
ColumnTypeConstraints
iduuidPK
customer_iduuidNOT NULL, FK customers.id ON DELETE CASCADE
typetextNOT NULL. Enum: shipping, billing
is_defaultbooleanNOT NULL, default false
first_nametextNOT NULL
last_nametextNOT NULL
line1textNOT NULL
line2text
citytextNOT NULL
statetext
postal_codetext
countrytextNOT NULL

ColumnTypeConstraints
iduuidPK
entity_iduuidNOT NULL, FK sellable_entities.id ON DELETE CASCADE
variant_iduuidFK variants.id ON DELETE CASCADE
currencytextNOT NULL
amountintegerNOT NULL
customer_group_idtext
min_quantityinteger
max_quantityinteger
valid_fromtimestamptz
valid_untiltimestamptz

Indexes: (entity_id, variant_id, currency), (valid_from, valid_until).


ColumnTypeConstraints
iduuidPK
codetextUNIQUE
nametextNOT NULL
typetextEnum: percentage_off_order, fixed_off_order, percentage_off_item, fixed_off_item, free_shipping, buy_x_get_y
valueintegerNOT NULL, default 0
is_automaticbooleanNOT NULL, default false
is_activebooleanNOT NULL, default true
priorityintegerNOT NULL, default 100
usage_limit_totalinteger
usage_limit_per_customerinteger
valid_fromtimestamptz
valid_untiltimestamptz

ColumnTypeConstraints
iduuidPK
entity_typetextNOT NULL
entity_idtextNOT NULL
eventtextNOT NULL
payloadjsonbNOT NULL, default '{}'
actor_idtext
actor_typetext
request_idtext
created_attimestamptzNOT NULL, default now()

Index: (entity_type, entity_id).


ColumnTypeConstraints
iduuidPK
urltextNOT NULL
secrettextNOT NULL
eventsjsonbNOT NULL
is_activebooleanNOT NULL, default true
ColumnTypeConstraints
iduuidPK
endpoint_iduuidNOT NULL, FK webhook_endpoints.id
event_nametextNOT NULL
payloadjsonbNOT NULL
status_codeinteger
attempt_countintegerNOT NULL, default 0
next_retry_attimestamptz
delivered_attimestamptz
failed_attimestamptz

ColumnTypeConstraints
iduuidPK
queuetextNOT NULL, default 'default'
task_slugtextNOT NULL
inputjsonbNOT NULL, default '{}'
outputjsonb
statustextEnum: pending, processing, succeeded, failed
attemptsintegerNOT NULL, default 0
max_attemptsintegerNOT NULL, default 5
errortext
wait_untiltimestamptz
concurrency_keytext
processing_started_attimestamptz
completed_attimestamptz

ColumnTypeConstraints
iduuidPK
order_iduuidNOT NULL, FK orders.id ON DELETE CASCADE
typetextNOT NULL
statustextNOT NULL, default 'pending'
carriertext
tracking_numbertext
tracking_urltext
estimated_deliverytimestamptz
shipped_attimestamptz
delivered_attimestamptz
download_urltextFor digital downloads
download_expires_attimestamptz
max_downloadsinteger
download_countintegerNOT NULL, default 0

Added by @porulle/plugin-pos.

ColumnTypeConstraints
iduuidPK
nametextNOT NULL
codetextNOT NULL
typetextEnum: register, tablet, mobile, kiosk
is_activebooleanNOT NULL, default true

Unique: (organization_id, code).

ColumnTypeConstraints
iduuidPK
terminal_iduuidNOT NULL, FK pos_terminals.id ON DELETE CASCADE
operator_idtextNOT NULL
statustextEnum: open, closed
opening_floatintegerNOT NULL, default 0
closing_countinteger
expected_cashinteger
cash_varianceinteger
sales_countintegerNOT NULL, default 0
sales_totalintegerNOT NULL, default 0
ColumnTypeConstraints
iduuidPK
shift_iduuidNOT NULL, FK pos_shifts.id ON DELETE CASCADE
terminal_iduuidNOT NULL, FK pos_terminals.id
cart_iduuidNOT NULL
order_iduuidSet after checkout completes
typetextEnum: sale, return, exchange
statustextEnum: open, held, completed, voided
receipt_numbertextSequential per terminal per day (e.g., MC1-0001)
totalintegerNOT NULL, default 0
void_reasontextRequired when voiding
ColumnTypeConstraints
iduuidPK
transaction_iduuidNOT NULL, FK pos_transactions.id ON DELETE CASCADE
methodtextEnum: cash, card, gift_card, store_credit, other
amountintegerNOT NULL
change_givenintegerNOT NULL, default 0
referencetextCard last 4, gift card code, auth code
statustextEnum: collected, refunded