Skip to main content

Schema atlas

Generated from source

108 tables, walked from 155 migration files. Regenerated by scripts/gen-schema-atlas.mjs from the kvick-bike/migrations/ directory — DO NOT hand-edit this file; edits are overwritten. Last generated: 2026-09-19. M### in the "Since" column names the migration file (e.g. M070 = migrations/070_rental_bookings.sql).

Table index​

TableColsIndexesTriggersSince
_bak107_zz200M107
access_checks600M159
announcement_images600M144
audit_events29110M040
audit_log800M001
audit_mutations1030M040
audit_row_changes710M040
brand_groups410M133
bulk_items700M027
categories1210M018
channel_dealers1010M126
consignment_payouts1720M118
customer_account_ledger1120M003
customer_bikes2244M003
customer_discounts510M059
customer_emails820M038
customer_family_links510M011
customer_family_members716M015
customer_loyalty_ledger820M116
customer_marketing_preferences900M003
customer_notes810M003
customer_phones820M038
customer_pickup_authorisations910M115
customer_tags400M003
customer_wishlist910M115
customers4529M002
customers_yoy_summary610M017
device_unlocks810M158
discount_actions610M012
discount_conditions610M012
discounts1810M012
duty_templates1310M144
feature_registry1010M044
gift_cards910M038
held_sales1920M027
idempotency_records920M137
inventory3330M019
inventory_images600M091
inventory_locations1200M019
inventory_movements1440M019
inventory_order_queue1430M020
inventory_units3030M054
kit_components510M061
manufacturers910M018
migration_jobs1710M049
migration_presets900M049
note_images600M129
payments1520M027
permissions500M008
product_barcodes830M018
product_variants1630M018
products3040M018
purchase_order_lines2250M021
purchase_orders2420M025
recovery_codes700M158
rental_addons810M102
rental_booking_bikes1340M070
rental_booking_riders510M070
rental_bookings4010M079
rental_drafts300M099
rental_hold_policy300M097
rental_id_images600M096
rental_rate_cards1410M119
rental_waivers2430M093
request_limits420M157
rma1320M024
rma_lines710M024
role_permissions200M008
roles800M008
search_synonym_groups710M010
search_synonym_terms520M010
service_bike_locations610M104
service_menu1420M030
service_menu_parts520M145
service_signoffs1210M112
service_ticket_lines2540M030
service_ticket_messages810M030
service_ticket_status_history820M030
service_tickets5050M030
service_urgency_levels610M104
session_devices210M160
sessions410M001
shop_announcements1110M144
shop_config6400M035
shop_note_comments610M148
shop_note_reads310M149
shop_notes1130M127
signin_devices500M160
signin_lockouts810M160
staff1810M001
staff_duties1730M144
staff_feature_state810M043
staff_messages720M144
staff_permission_overrides800M008
staff_screen_permissions300M008
subcategories1230M018
supplier_products1230M020
suppliers2210M020
tags600M003
tax_categories1200M018
tax_rates1000M018
transaction_discounts920M027
transaction_lines2430M027
transaction_taxes720M027
transactions3460M004
unlock_accounts900M158
unlock_codes700M158
website_content710M122

Dropped​

Tables that appeared in an earlier migration and were later DROPped:

  • search_customers_fts

_bak107_zz​

Introduced: M107. Columns: 2. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
kindTEXTyesM107
idINTEGERyesM107

access_checks​

Introduced: M159. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
dayTEXTnoCHECK (day GLOB '[0-9][0-9][0-9][0-9]-[0-9]…M159
outcomeTEXTnoCHECK (outcome IN ('ok', 'would_refuse', 'r…M159
reasonTEXTno''M159
nINTEGERno1CHECK (n >= 1)M159
first_atTEXTno(datetime('now')M159
last_atTEXTno(datetime('now')M159

Checks (table-level):

  • ((outcome = 'ok' AND reason = '') OR (outcome <> 'ok' AND reason IN ( 'no_token', 'malformed', 'wrong_algorithm', 'unknown_key', 'keys_unavailable', 'bad_signature', 'wrong_issuer', 'wrong_audience', 'expired', 'not_yet_valid', 'not_configured'))) (M159)

announcement_images​

Introduced: M144. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM144
mimeTEXTnoM144
dataTEXTnoM144
bytesINTEGERyesM144
uploaded_by_staff_idINTEGERyesFK → staff.idM144
created_atTEXTnoCURRENT_TIMESTAMPM144

audit_events​

Introduced: M040. Columns: 29. Indexes: 11. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM040
occurred_atTEXTno(datetime('now')M040
occurred_at_localTEXTyesM040
categoryTEXTnoM040
event_typeTEXTnoM040
severityTEXTno'info'M040
actor_typeTEXTno'staff'M040
actor_staff_idINTEGERyesFK → staff.idM040
actor_session_idINTEGERyesM040
actor_labelTEXTno'unknown'M040
actor_ipTEXTyesM040
actor_user_agentTEXTyesM040
actor_register_idTEXTyesM040
target_tableTEXTyesM040
target_record_idINTEGERyesM040
target_labelTEXTyesM040
context_ticket_idINTEGERyesM040
context_transaction_idINTEGERyesM040
context_customer_idINTEGERyesM040
context_screenTEXTyesM040
detail_tableTEXTyesM040
detail_idINTEGERyesM040
previous_event_idINTEGERyesFK → audit_events.idM040
previous_hashTEXTyesM040
current_hashTEXTnoM040
duration_msINTEGERyesM040
outcomeTEXTno'success'M040
summaryTEXTnoM040
build_versionTEXTyesM040
Indexes:
  • idx_audit_occurred — (occurred_at) (M040)
  • idx_audit_category — (category, occurred_at) (M040)
  • idx_audit_event_type — (event_type, occurred_at) (M040)
  • idx_audit_actor_staff — (actor_staff_id, occurred_at) (M040)
  • idx_audit_target — (target_table, target_record_id) (M040)
  • idx_audit_ctx_txn — (context_transaction_id) · WHERE context_transaction_id IS NOT NULL (M040)
  • idx_audit_ctx_customer — (context_customer_id) · WHERE context_customer_id IS NOT NULL (M040)
  • idx_audit_ctx_ticket — (context_ticket_id) · WHERE context_ticket_id IS NOT NULL (M040)
  • idx_audit_severity — (severity) · WHERE severity IN ('warning','error','critical') (M040)
  • idx_audit_outcome — (outcome) · WHERE outcome != 'success' (M040)
  • idx_audit_chain — (current_hash) (M040)

audit_log​

Introduced: M001. Columns: 8. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM001
tsTEXTno(datetime('now')M001
actor_staff_idINTEGERyesFK → staff.idM001
actor_nameTEXTyesM001
actionTEXTnoM001
detailTEXTyesM001
prev_hashTEXTyesM001
hashTEXTnoM001

audit_mutations​

Introduced: M040. Columns: 10. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM040
event_idINTEGERnoFK → audit_events.idM040
operationTEXTnoM040
before_jsonTEXTyesM040
after_jsonTEXTyesM040
changed_columns_jsonTEXTyesM040
diff_jsonTEXTyesM040
trigger_sourceTEXTno'user_action'M040
trigger_event_idINTEGERyesFK → audit_events.idM040
rows_affectedINTEGERno1M040
Indexes:
  • idx_mutations_event — (event_id) (M040)
  • idx_mutations_operation — (operation) (M040)
  • idx_mutations_cascade — (trigger_event_id) · WHERE trigger_event_id IS NOT NULL (M040)

audit_row_changes​

Introduced: M040. Columns: 7. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM040
changed_atTEXTno(datetime('now')M040
table_nameTEXTnoM040
row_idINTEGERyesM040
opTEXTnoM040
before_jsonTEXTyesM040
after_jsonTEXTyesM040
Indexes:
  • idx_rowchg — (table_name, row_id, id) (M040)

brand_groups​

Introduced: M133. Columns: 4. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
group_nameTEXTnoM133
memberTEXTnoM133
noteTEXTyesM133
created_atTEXTnoCURRENT_TIMESTAMPM133
Indexes:
  • idx_brand_groups_member — (member) (M133)

bulk_items​

Introduced: M027. Columns: 7. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
slugTEXTnoM027
nameTEXTnoM027
price_centsINTEGERnoCHECK (price_cents >= 0)M027
sort_orderINTEGERno0M027
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M027
created_atTEXTnoCURRENT_TIMESTAMPM027

categories​

Introduced: M018. Columns: 12. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
codeTEXTyesM018
nameTEXTnoM018
descriptionTEXTyesM018
default_tax_category_idINTEGERyesFK → tax_categories.idM018
is_discountableINTEGERno1CHECK (is_discountable IN (0,1))M018
is_loyalty_eligibleINTEGERno1CHECK (is_loyalty_eligible IN (0,1))M018
display_orderINTEGERno0M018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
aim_idINTEGERyesM018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018
Indexes:
  • idx_categories_aim_u — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M130)

channel_dealers​

Introduced: M126. Columns: 10. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM126
nameTEXTnoM126
cityTEXTyesM126
provinceTEXTyesM126
is_selfINTEGERno0M126
is_activeINTEGERno1M126
connected_atTEXTyesM126
notesTEXTyesM126
created_atTEXTnoCURRENT_TIMESTAMPM126
updated_atTEXTnoCURRENT_TIMESTAMPM126
Indexes:
  • idx_channel_dealers_self — UNIQUE · (is_self) · WHERE is_self = 1 (M126)

consignment_payouts​

Introduced: M118. Columns: 17. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM118
consignor_customer_idINTEGERnoFK → customers.idM118
unit_idINTEGERyesFK → inventory_units.idM118
variant_idINTEGERyesFK → product_variants.idM118
descriptionTEXTnoM118
transaction_idINTEGERyesFK → transactions.idM118
transaction_line_idINTEGERyesFK → transaction_lines.idM118
sold_centsINTEGERnoM118
split_pctINTEGERyesM118
owed_centsINTEGERno0M118
paid_centsINTEGERno0M118
paid_atTEXTyesM118
paid_methodTEXTyesM118
paid_by_staff_idINTEGERyesFK → staff.idM118
notesTEXTyesM118
created_atTEXTnoCURRENT_TIMESTAMPM118
updated_atTEXTnoCURRENT_TIMESTAMPM118
Indexes:
  • idx_consign_payout_consignor — (consignor_customer_id) (M118)
  • idx_consign_payout_line — UNIQUE · (transaction_line_id) · WHERE transaction_line_id IS NOT NULL (M118)

customer_account_ledger​

Introduced: M003. Columns: 11. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM003
customer_idINTEGERnoFK → customers.idM003
occurred_atTEXTnoCURRENT_TIMESTAMPM003
amount_centsINTEGERnoM003
entry_typeTEXTnoM003
reference_kindTEXTyesM003
reference_idINTEGERyesM003
staff_idINTEGERyesM003
notesTEXTyesM003
created_atTEXTnoCURRENT_TIMESTAMPM003
aim_idINTEGERyesM038
Indexes:
  • idx_acctledger_customer — (customer_id, occurred_at DESC) (M003)
  • idx_acct_ledger_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

customer_bikes​

Introduced: M003. Columns: 22. Indexes: 4. Triggers: 4.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM003
customer_idINTEGERnoM003
equipment_typeTEXTno'bike'M003
brandTEXTyesM003
modelTEXTyesM003
model_yearINTEGERyesM003
serial_numberTEXTyesM003
colorTEXTyesM003
frame_sizeTEXTyesM003
notesTEXTyesM003
is_activeINTEGERno1M003
retired_atTEXTyesM003
retired_reasonTEXTyesM003
created_atTEXTnoCURRENT_TIMESTAMPM003
updated_atTEXTnoCURRENT_TIMESTAMPM003
sourceTEXTyesM114
sold_transaction_idINTEGERyesFK → transactions.idM114
warranty_starts_atTEXTyesM114
service_interval_daysINTEGERyesM114
previous_owner_customer_idINTEGERyesFK → customers.idM114
transferred_atTEXTyesM114
gifted_by_customer_idINTEGERyesFK → customers.idM114

Foreign keys (table-level):

  • customer_id → customers(id) (M003)

Indexes:

  • idx_cbikes_customer — (customer_id) · WHERE is_active=1 (M003)
  • idx_customer_bikes_serial — (serial_number) (M114)
  • idx_customer_bikes_prev_owner — (previous_owner_customer_id) (M114)
  • idx_customer_bikes_cust_bike_u — UNIQUE · (customer_id, brand, model, model_year, serial_number) (M138)

Triggers:

  • trg_search_cust_fts_bike_ai — AFTER INSERT (M113)
  • trg_search_cust_fts_bike_au — AFTER UPDATE (M113)
  • trg_search_cust_fts_bike_ad — AFTER DELETE (M113)
  • trg_search_cust_fts_bike_au — AFTER UPDATE (M117)

customer_discounts​

Introduced: M059. Columns: 5. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM059
customer_idINTEGERnoM059
discount_idINTEGERnoM059
created_atTEXTnoCURRENT_TIMESTAMPM059
created_byINTEGERyesM059

Unique (table-level):

  • (customer_id, discount_id) (M059)

Indexes:

  • idx_customer_discounts_customer — (customer_id) (M059)

customer_emails​

Introduced: M038. Columns: 8. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM038
customer_idINTEGERnoFK → customers.idM038
email_addressTEXTnoM038
email_typeTEXTyes'primary'M038
is_primaryINTEGERno0M038
is_subscribedINTEGERno1M038
aim_idINTEGERyesM038
created_atTEXTyesCURRENT_TIMESTAMPM038
Indexes:
  • idx_customer_emails_cust — (customer_id) (M038)
  • idx_customer_emails_cust_addr_u — UNIQUE · (customer_id, email_address) · WHERE email_address IS NOT NULL (M135)

Introduced: M011. Columns: 5. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM011
customer_a_idINTEGERnoM011
customer_b_idINTEGERnoM011
created_atTEXTnoCURRENT_TIMESTAMPM011
created_by_staff_idINTEGERyesM011

Foreign keys (table-level):

  • customer_a_id → customers(id) (M011)
  • customer_b_id → customers(id) (M011)

Unique (table-level):

  • (customer_a_id, customer_b_id) (M011)

Checks (table-level):

  • (customer_a_id < customer_b_id) (M011)

Indexes:

  • idx_cfamily_b — (customer_b_id) (M011)

customer_family_members​

Introduced: M015. Columns: 7. Indexes: 1. Triggers: 6.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM015
customer_idINTEGERnoFK → customers.idM015
nameTEXTnoM015
relationshipTEXTyesM015
phoneTEXTyesM015
is_minorINTEGERno0CHECK (is_minor IN (0,1))M015
created_atTEXTnoCURRENT_TIMESTAMPM015
Indexes:
  • idx_customer_family_members_customer — (customer_id) (M015)

Triggers:

  • trg_search_cust_fts_family_ai — AFTER INSERT (M031)
  • trg_search_cust_fts_family_au — AFTER UPDATE (M031)
  • trg_search_cust_fts_family_ad — AFTER DELETE (M031)
  • trg_search_cust_fts_family_ai — AFTER INSERT (M113)
  • trg_search_cust_fts_family_au — AFTER UPDATE (M113)
  • trg_search_cust_fts_family_ad — AFTER DELETE (M113)

customer_loyalty_ledger​

Introduced: M116. Columns: 8. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM116
customer_idINTEGERnoFK → customers.idM116
pointsINTEGERnoM116
reasonTEXTnoM116
transaction_idINTEGERyesFK → transactions.idM116
noteTEXTyesM116
staff_idINTEGERyesFK → staff.idM116
created_atTEXTnoCURRENT_TIMESTAMPM116
Indexes:
  • idx_loyalty_ledger_customer — (customer_id, id) (M116)
  • idx_loyalty_ledger_sale — UNIQUE · (transaction_id, reason) · WHERE transaction_id IS NOT NULL (M116)

customer_marketing_preferences​

Introduced: M003. Columns: 9. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM003
customer_idINTEGERnoM003
channelTEXTnoM003
is_subscribedINTEGERno0M003
consent_sourceTEXTyesM003
consent_atTEXTyesM003
unsubscribed_atTEXTyesM003
created_atTEXTnoCURRENT_TIMESTAMPM003
updated_atTEXTnoCURRENT_TIMESTAMPM003

Foreign keys (table-level):

  • customer_id → customers(id) (M003)

Unique (table-level):

  • (customer_id, channel) (M003)

customer_notes​

Introduced: M003. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM003
customer_idINTEGERnoM003
author_staff_idINTEGERyesM003
note_textTEXTnoM003
is_pinnedINTEGERno0M003
is_deletedINTEGERno0M003
created_atTEXTnoCURRENT_TIMESTAMPM003
updated_atTEXTnoCURRENT_TIMESTAMPM003

Foreign keys (table-level):

  • customer_id → customers(id) (M003)

Indexes:

  • idx_cnotes_customer — (customer_id) · WHERE is_deleted=0 (M003)

customer_phones​

Introduced: M038. Columns: 8. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM038
customer_idINTEGERnoFK → customers.idM038
phone_numberTEXTnoM038
phone_typeTEXTyes'mobile'M038
is_primaryINTEGERno0M038
is_sms_capableINTEGERno1M038
aim_idINTEGERyesM038
created_atTEXTyesCURRENT_TIMESTAMPM038
Indexes:
  • idx_customer_phones_cust — (customer_id) (M038)
  • idx_customer_phones_cust_num_u — UNIQUE · (customer_id, phone_number) · WHERE phone_number IS NOT NULL (M138)

customer_pickup_authorisations​

Introduced: M115. Columns: 9. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM115
customer_idINTEGERnoFK → customers.idM115
nameTEXTnoM115
relationshipTEXTyesM115
noteTEXTyesM115
valid_untilTEXTyesM115
created_by_staff_idINTEGERyesFK → staff.idM115
created_atTEXTnoCURRENT_TIMESTAMPM115
is_revokedINTEGERno0CHECK (is_revoked IN (0,1))M115
Indexes:
  • idx_pickup_auth_customer — (customer_id, is_revoked) (M115)

customer_tags​

Introduced: M003. Columns: 4. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
customer_idINTEGERnoM003
tag_idINTEGERnoM003
applied_atTEXTnoCURRENT_TIMESTAMPM003
applied_by_staff_idINTEGERyesM003

Foreign keys (table-level):

  • customer_id → customers(id) (M003)
  • tag_id → tags(id) (M003)

customer_wishlist​

Introduced: M115. Columns: 9. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM115
customer_idINTEGERnoFK → customers.idM115
variant_idINTEGERyesFK → product_variants.idM115
descriptionTEXTnoM115
noteTEXTyesM115
added_by_staff_idINTEGERyesFK → staff.idM115
created_atTEXTnoCURRENT_TIMESTAMPM115
purchased_atTEXTyesM115
purchased_transaction_idINTEGERyesFK → transactions.idM115
Indexes:
  • idx_wishlist_customer — (customer_id) (M115)

customers​

Introduced: M002. Columns: 45. Indexes: 2. Triggers: 9.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM002
account_numberINTEGERyesM002
display_nameTEXTnoM002
primary_phoneTEXTyesM002
primary_emailTEXTyesM002
pricing_tierTEXTno'a'M002
popup_noteTEXTyesM002
general_notesTEXTyesM002
credit_limit_centsINTEGERno0M002
customer_statusTEXTno'active'M002
is_tax_exemptINTEGERno0M002
customer_sinceTEXTyesCURRENT_TIMESTAMPM002
is_deletedINTEGERno0M002
created_atTEXTyesCURRENT_TIMESTAMPM002
updated_atTEXTyesCURRENT_TIMESTAMPM002
versionINTEGERno1M002
legal_nameTEXTyesM003
is_businessINTEGERno0M003
primary_phone_typeTEXTyes'mobile'M003
tax_exempt_certificateTEXTyesM003
tax_exempt_categoryTEXTyesM003
keywordsTEXTyesM003
is_consignorINTEGERno0M003
deleted_atTEXTyesM003
external_aim_idINTEGERyesM003
merged_into_customer_idINTEGERyesM003
address_line1TEXTyesM003
address_line2TEXTyesM003
cityTEXTyesM003
provinceTEXTyesM003
postal_codeTEXTyesM003
loyalty_numberINTEGERyesM005
loyalty_pointsINTEGERno0M005
loyalty_enrolled_atTEXTyesM005
is_minorINTEGERno0M011
sales_discount_idINTEGERyesM013
service_discount_idINTEGERyesM013
how_heardTEXTyesM115
goes_byTEXTyesM115
preferred_contactTEXTyesM115
date_of_birthTEXTyesM115
deceased_atTEXTyesM115
consignment_split_pctINTEGERyesM115
consignment_payout_methodTEXTyesM115
consignment_expires_atTEXTyesM115
Indexes:
  • idx_customers_name — (display_name) · WHERE is_deleted=0 (M002)
  • idx_customers_account — (account_number) (M002)

Triggers:

  • trg_search_cust_fts_ai — AFTER INSERT (M010)
  • trg_search_cust_fts_au — AFTER UPDATE (M010)
  • trg_search_cust_fts_ad — AFTER DELETE (M010)
  • trg_search_cust_fts_ai — AFTER INSERT (M031)
  • trg_search_cust_fts_au — AFTER UPDATE (M031)
  • trg_search_cust_fts_ad — AFTER DELETE (M031)
  • trg_search_cust_fts_ai — AFTER INSERT (M113)
  • trg_search_cust_fts_au — AFTER UPDATE (M113)
  • trg_search_cust_fts_ad — AFTER DELETE (M113)

customers_yoy_summary​

Introduced: M017. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
customer_idINTEGERyesPK · FK → customers.idM017
t12m_spend_centsINTEGERno0M017
p12m_spend_centsINTEGERno0M017
yoy_delta_centsINTEGERno0M017
yoy_bucketTEXTno'zero'CHECK (yoy_bucket IN ('up','down','flat','n…M017
computed_atTEXTno(datetime('now')M017
Indexes:
  • idx_yoy_bucket — (yoy_bucket) (M017)

device_unlocks​

Introduced: M158. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
token_hashTEXTyesPKM158
account_idINTEGERyesM158
methodTEXTnoM158
created_atTEXTno(datetime('now')M158
expires_atTEXTnoM158
revoked_atTEXTyesM158
ipTEXTyesM158
user_agentTEXTyesM158
Indexes:
  • idx_device_unlocks_open — (revoked_at, expires_at) (M158)

discount_actions​

Introduced: M012. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM012
discount_idINTEGERnoFK → discounts.idM012
typeTEXTnoCHECK (type IN ('percent','dollar','set_pri…M012
targetTEXTno'cart'CHECK (target IN ('cart','category','line'))M012
valueTEXTno'{}'M012
created_atTEXTnoCURRENT_TIMESTAMPM012
Indexes:
  • idx_discount_actions_discount — (discount_id) (M012)

discount_conditions​

Introduced: M012. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM012
discount_idINTEGERnoFK → discounts.idM012
typeTEXTnoCHECK (type IN ( 'customer_attr','product_a…M012
operatorTEXTno'eq'CHECK (operator IN ('eq','gte','lte','in'))M012
valueTEXTno'{}'M012
created_atTEXTnoCURRENT_TIMESTAMPM012
Indexes:
  • idx_discount_conditions_discount — (discount_id) (M012)

discounts​

Introduced: M012. Columns: 18. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM012
nameTEXTnoM012
descriptionTEXTyesM012
start_atTEXTyesM012
end_atTEXTyesM012
stackableINTEGERno0CHECK (stackable IN (0,1))M012
manager_threshold_centsINTEGERyesM012
max_uses_totalINTEGERyesM012
max_uses_per_customerINTEGERyesM012
is_activeINTEGERno1CHECK (is_active IN (0,1))M012
created_by_staff_idINTEGERyesFK → staff.idM012
created_atTEXTnoCURRENT_TIMESTAMPM012
updated_atTEXTnoCURRENT_TIMESTAMPM012
archived_atTEXTyesM012
kindTEXTno'cart'CHECK (kind IN ('customer','cart'))M013
departmentTEXTyesCHECK (department IS NULL OR department IN …M013
applies_salesINTEGERno0CHECK (applies_sales IN (0,1))M014
applies_serviceINTEGERno0CHECK (applies_service IN (0,1))M014
Indexes:
  • idx_discounts_active — (is_active, archived_at) (M012)

duty_templates​

Introduced: M144. Columns: 13. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM144
titleTEXTnoM144
bodyTEXTyesM144
default_assigned_to_staff_idINTEGERyesFK → staff.idM144
recurrenceTEXTno'adhoc'CHECK (recurrence IN ('daily','weekly','adh…M144
recurrence_daysTEXTyesM144
activeINTEGERno1CHECK (active IN (0,1))M144
created_by_staff_idINTEGERnoFK → staff.idM144
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M144
deleted_atTEXTyesM144
versionINTEGERno1M144
created_atTEXTnoCURRENT_TIMESTAMPM144
updated_atTEXTnoCURRENT_TIMESTAMPM144

Checks (table-level):

  • (length(title) BETWEEN 1 AND 200) (M144)

Indexes:

  • idx_duty_templates_active — (active) · WHERE is_deleted = 0 (M144)

feature_registry​

Introduced: M044. Columns: 10. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
feature_keyTEXTyesPKM044
module_keyTEXTnoM044
display_nameTEXTnoM044
descriptionTEXTnoM044
frequency_classTEXTnoCHECK (frequency_class IN ('high','medium',…M044
default_decay_usesINTEGERnoM044
default_decay_daysINTEGERnoM044
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M044
created_atINTEGERno(unixepoch()M044
updated_atINTEGERno(unixepoch()M044
Indexes:
  • idx_feature_registry_module — (module_key) (M044)

gift_cards​

Introduced: M038. Columns: 9. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM038
codeTEXTyesM038
customer_idINTEGERyesFK → customers.idM038
balance_centsINTEGERno0M038
initial_centsINTEGERno0M038
issued_atTEXTyesM038
is_activeINTEGERno1M038
aim_idINTEGERyesM038
created_atTEXTyesCURRENT_TIMESTAMPM038
Indexes:
  • idx_gift_cards_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

held_sales​

Introduced: M027. Columns: 19. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
held_atTEXTnoCURRENT_TIMESTAMPM027
held_by_staff_idINTEGERyesFK → staff.idM027
held_by_staff_nameTEXTyesM027
customer_idINTEGERyesM027
customer_nameTEXTyesM027
customer_account_numberTEXTyesM027
customer_primary_phoneTEXTyesM027
customer_primary_emailTEXTyesM027
ticket_idINTEGERyesM027
ticket_numberTEXTyesM027
sourceTEXTyesM027
subtotal_centsINTEGERno0M027
total_centsINTEGERno0M027
line_countINTEGERno0M027
till_jsonTEXTno'[]'M027
notesTEXTyesM027
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M027
updated_atTEXTnoCURRENT_TIMESTAMPM027
Indexes:
  • idx_parked_active — (is_deleted, parked_at DESC) (M027)
  • idx_held_active — (is_deleted, held_at DESC) (M047)

idempotency_records​

Introduced: M137. Columns: 9. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM137
idempotency_keyTEXTnoM137
endpointTEXTnoM137
request_body_sha256TEXTnoM137
response_statusINTEGERnoM137
response_bodyTEXTnoM137
created_atTEXTnoCURRENT_TIMESTAMPM137
expires_atTEXTyesM137
actor_staff_idINTEGERyesFK → staff.idM137
Indexes:
  • idx_idempotency_endpoint_created — (endpoint, created_at) (M137)
  • idx_idempotency_expires — (expires_at) · WHERE expires_at IS NOT NULL (M137)

inventory​

Introduced: M019. Columns: 33. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM019
variant_idINTEGERnoFK → product_variants.idM019
location_idINTEGERnoFK → inventory_locations.idM019
quantity_on_handINTEGERno0M019
quantity_allocated_saleINTEGERno0M019
quantity_allocated_serviceINTEGERno0M019
quantity_allocated_layawayINTEGERno0M019
quantity_allocated_loanerINTEGERno0M019
quantity_allocated_rentalINTEGERno0M019
quantity_allocated_onlineINTEGERno0M019
quantity_allocated_special_orderINTEGERno0M019
quantity_availableINTEGERno0M019
cost_centsINTEGERyesM019
freight_centsINTEGERyesM019
weighted_avg_cost_centsINTEGERyesM019
retail_price_centsINTEGERyesM019
selling_price_centsINTEGERyesM019
minimum_price_centsINTEGERyesM019
online_sale_price_centsINTEGERyesM019
reorder_pointINTEGERyesM019
reorder_maxINTEGERyesM019
hold_back_quantityINTEGERyesM019
tax_category_idINTEGERyesFK → tax_categories.idM019
is_consignmentINTEGERno0CHECK (is_consignment IN (0,1))M019
consignor_customer_idINTEGERyesFK → customers.idM019
statusTEXTno'active'CHECK (status IN ('active','inactive'))M019
last_physical_count_atTEXTyesM019
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M019
aim_idINTEGERyesM019
versionINTEGERno1M019
created_atTEXTnoCURRENT_TIMESTAMPM019
updated_atTEXTnoCURRENT_TIMESTAMPM019
rental_rate_centsINTEGERyesM065

Unique (table-level):

  • (variant_id, location_id) (M019)

Indexes:

  • idx_inventory_variant — (variant_id) (M019)
  • idx_inventory_reorder — (reorder_point) · WHERE reorder_point IS NOT NULL (M019)
  • idx_inventory_one_live_row_per_variant_location — UNIQUE · (variant_id, location_id) · WHERE is_deleted = 0 (M156)

inventory_images​

Introduced: M091. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM091
mimeTEXTnoM091
dataTEXTnoM091
bytesINTEGERno0M091
uploaded_by_staff_idINTEGERyesFK → staff.idM091
created_atTEXTno(datetime('now')M091

inventory_locations​

Introduced: M019. Columns: 12. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM019
nameTEXTnoM019
address_line_1TEXTyesM019
cityTEXTyesM019
provinceTEXTyesM019
postal_codeTEXTyesM019
is_defaultINTEGERno0CHECK (is_default IN (0,1))M019
is_sales_floorINTEGERno1CHECK (is_sales_floor IN (0,1))M019
is_activeINTEGERno1CHECK (is_active IN (0,1))M019
aim_idINTEGERyesM019
created_atTEXTnoCURRENT_TIMESTAMPM019
updated_atTEXTnoCURRENT_TIMESTAMPM019

inventory_movements​

Introduced: M019. Columns: 14. Indexes: 4. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM019
inventory_idINTEGERnoFK → inventory.idM019
variant_idINTEGERnoFK → product_variants.idM019
location_idINTEGERnoFK → inventory_locations.idM019
movement_typeTEXTnoCHECK (movement_type IN ('receive','sale','…M019
quantity_changeINTEGERnoM019
new_quantity_on_handINTEGERnoM019
reasonTEXTyesM019
reference_tableTEXTyesM019
reference_idINTEGERyesM019
unit_cost_centsINTEGERyesM019
staff_idINTEGERyesFK → staff.idM019
occurred_atTEXTnoCURRENT_TIMESTAMPM019
created_atTEXTnoCURRENT_TIMESTAMPM019
Indexes:
  • idx_inv_movements_variant — (variant_id, occurred_at DESC) (M019)
  • idx_inv_movements_inventory — (inventory_id, occurred_at DESC) (M019)
  • idx_inv_movements_type — (movement_type, occurred_at DESC) (M019)
  • idx_inv_movements_reference — (reference_table, reference_id) (M019)

inventory_order_queue​

Introduced: M020. Columns: 14. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM020
variant_idINTEGERyesFK → product_variants.idM020
supplier_idINTEGERyesFK → suppliers.idM020
supplier_name_freeTEXTyesM020
quantityINTEGERno1M020
statusTEXTno'pending'CHECK (status IN ('pending','ordered','rece…M020
added_by_staff_idINTEGERyesFK → staff.idM020
customer_idINTEGERyesFK → customers.idM020
source_po_line_idINTEGERyesFK → purchase_order_lines.idM020
notesTEXTyesM020
created_atTEXTnoCURRENT_TIMESTAMPM020
updated_atTEXTnoCURRENT_TIMESTAMPM020
unit_cost_centsINTEGERyesM026
special_order_transaction_idINTEGERyesFK → transactions.idM033
Indexes:
  • idx_order_queue_status — (status) (M020)
  • idx_order_queue_supplier — (supplier_id, status) (M020)
  • idx_order_queue_special_order — (special_order_transaction_id) · WHERE special_order_transaction_id IS NOT NULL (M033)

inventory_units​

Introduced: M054. Columns: 30. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM054
inventory_idINTEGERnoFK → inventory.idM054
variant_idINTEGERnoFK → product_variants.idM054
location_idINTEGERnoFK → inventory_locations.idM054
serial_numberTEXTyesM054
statusTEXTno'in_stock'CHECK (status IN ('on_order','in_stock','so…M054
cost_centsINTEGERyesM054
received_atTEXTyesM054
acquired_from_customer_idINTEGERyesFK → customers.idM054
notesTEXTyesM054
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M054
aim_idINTEGERyesM054
versionINTEGERno1M054
created_atTEXTnoCURRENT_TIMESTAMPM054
updated_atTEXTnoCURRENT_TIMESTAMPM054
is_rentalINTEGERno0CHECK (is_rental IN (0,1))M067
rental_categoryTEXTyesM067
rental_rate_centsINTEGERyesM067
is_consignmentINTEGERno0CHECK (is_consignment IN (0,1))M068
is_trade_inINTEGERno0CHECK (is_trade_in IN (0,1))M068
is_usedINTEGERno0CHECK (is_used IN (0,1))M068
rental_rate_hourly_centsINTEGERyesM074
rental_rate_halfday_centsINTEGERyesM074
rental_rate_weekly_centsINTEGERyesM074
rental_damage_hold_centsINTEGERyesM077
image_idINTEGERyesFK → inventory_images.idM091
special_price_centsINTEGERyesM092
rental_descriptionTEXTyesM123
rental_fit_min_cmINTEGERyesM123
rental_fit_max_cmINTEGERyesM123
Indexes:
  • idx_inventory_units_inventory — (inventory_id, is_deleted) (M054)
  • idx_inventory_units_variant — (variant_id, is_deleted) (M054)
  • idx_inventory_units_serial — UNIQUE · (serial_number) · WHERE serial_number IS NOT NULL AND is_deleted = 0 (M054)

kit_components​

Introduced: M061. Columns: 5. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM061
kit_variant_idINTEGERnoM061
component_variant_idINTEGERnoM061
quantityINTEGERno1M061
created_atTEXTnoCURRENT_TIMESTAMPM061

Unique (table-level):

  • (kit_variant_id, component_variant_id) (M061)

Indexes:

  • idx_kit_components_kit — (kit_variant_id) (M061)

manufacturers​

Introduced: M018. Columns: 9. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
nameTEXTnoM018
display_nameTEXTyesM018
website_urlTEXTyesM018
b2b_portal_urlTEXTyesM018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
aim_idINTEGERyesM018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018
Indexes:
  • idx_manufacturers_aim_u — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M130)

migration_jobs​

Introduced: M049. Columns: 17. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM049
statusTEXTno'draft'CHECK (status IN ('draft','gating','confirm…M049
phaseTEXTyesM049
stepINTEGERno0M049
wipe_tablesTEXTno'[]'M049
keep_tablesTEXTno'[]'M049
load_entitiesTEXTno'[]'M049
bookmarkTEXTyesM049
gate_resultTEXTyesM049
parity_resultTEXTyesM049
snapshot_metaTEXTyesM049
errorTEXTyesM049
started_by_staff_idINTEGERyesFK → staff.idM049
started_atTEXTnoCURRENT_TIMESTAMPM049
finished_atTEXTyesM049
modeTEXTno'rebuild'M131
amend_beforeTEXTyesM131
Indexes:
  • idx_migjob_status — (status, id DESC) (M049)

migration_presets​

Introduced: M049. Columns: 9. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM049
nameTEXTnoM049
descriptionTEXTyesM049
wipe_tablesTEXTno'[]'M049
keep_tablesTEXTno'[]'M049
load_entitiesTEXTno'[]'M049
is_builtinINTEGERno0CHECK (is_builtin IN (0,1))M049
created_atTEXTnoCURRENT_TIMESTAMPM049
updated_atTEXTnoCURRENT_TIMESTAMPM049

note_images​

Introduced: M129. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM129
mimeTEXTnoM129
dataTEXTnoM129
bytesINTEGERyesM129
uploaded_by_staff_idINTEGERyesFK → staff.idM129
created_atTEXTnoCURRENT_TIMESTAMPM129

payments​

Introduced: M027. Columns: 15. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
transaction_idINTEGERnoFK → transactions.idM027
payment_methodTEXTnoM027
amount_centsINTEGERnoM027
card_last_fourTEXTyesM027
card_brandTEXTyesM027
reference_numberTEXTyesM027
rounding_centsINTEGERno0M027
is_refundINTEGERno0CHECK (is_refund IN (0,1))M027
refund_of_payment_idINTEGERyesFK → payments.idM027
statusTEXTno'completed'M027
occurred_atTEXTnoCURRENT_TIMESTAMPM027
created_atTEXTnoCURRENT_TIMESTAMPM027
staff_idINTEGERyesFK → staff.idM036
aim_idINTEGERyesM038
Indexes:
  • idx_payments_txn — (transaction_id) (M027)
  • idx_payments_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

permissions​

Introduced: M008. Columns: 5. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM008
nameTEXTnoM008
display_nameTEXTnoM008
descriptionTEXTyesM008
categoryTEXTnoM008

product_barcodes​

Introduced: M018. Columns: 8. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
variant_idINTEGERnoFK → product_variants.idM018
barcodeTEXTnoM018
barcode_typeTEXTno'unknown'CHECK (barcode_type IN ('upc','ean','code39…M018
is_primaryINTEGERno0CHECK (is_primary IN (0,1))M018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
aim_idINTEGERyesM018
created_atTEXTnoCURRENT_TIMESTAMPM018
Indexes:
  • idx_barcodes_variant — (variant_id) (M018)
  • idx_barcodes_barcode — (barcode) (M018)
  • idx_product_barcodes_variant_code_u — UNIQUE · (variant_id, barcode) · WHERE barcode IS NOT NULL (M135)

product_variants​

Introduced: M018. Columns: 16. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
product_idINTEGERnoFK → products.idM018
skuTEXTnoM018
manufacturer_part_numberTEXTyesM018
display_labelTEXTyesM018
is_discontinuedINTEGERno0CHECK (is_discontinued IN (0,1))M018
discontinued_atTEXTyesM018
replacement_variant_idINTEGERyesFK → product_variants.idM018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M018
aim_idINTEGERyesM018
versionINTEGERno1M018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018
is_bulkINTEGERno0CHECK (is_bulk IN (0,1))M039
image_idINTEGERyesFK → inventory_images.idM091
Indexes:
  • idx_variants_product — (product_id) (M018)
  • idx_variants_discontinued — (is_discontinued, is_active) (M018)
  • idx_variants_bulk — (is_bulk) · WHERE is_bulk = 1 (M039)

products​

Introduced: M018. Columns: 30. Indexes: 4. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
category_idINTEGERyesFK → categories.idM018
subcategory_idINTEGERyesFK → subcategories.idM018
manufacturer_idINTEGERyesFK → manufacturers.idM018
display_nameTEXTnoM018
model_numberTEXTyesM018
product_typeTEXTno'goods'CHECK (product_type IN ('goods','service','…M018
unit_labelTEXTno'each'M018
weight_gramsINTEGERyesM018
descriptionTEXTyesM018
short_descriptionTEXTyesM018
internal_notesTEXTyesM018
warranty_monthsINTEGERyesM018
default_tax_category_idINTEGERyesFK → tax_categories.idM018
stock_behaviorTEXTno'tracked'CHECK (stock_behavior IN ('tracked','untrac…M018
is_serializedINTEGERno0CHECK (is_serialized IN (0,1))M018
is_consignmentINTEGERno0CHECK (is_consignment IN (0,1))M018
is_loyalty_eligibleINTEGERno1CHECK (is_loyalty_eligible IN (0,1))M018
is_online_visibleINTEGERno0CHECK (is_online_visible IN (0,1))M018
online_descriptionTEXTyesM018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M018
aim_idINTEGERyesM018
versionINTEGERno1M018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018
is_trade_inINTEGERno0CHECK (is_trade_in IN (0,1))M063
is_rentalINTEGERno0CHECK (is_rental IN (0,1))M063
is_usedINTEGERno0CHECK (is_used IN (0,1))M063
rental_categoryTEXTyesM066
Indexes:
  • idx_products_category — (category_id) (M018)
  • idx_products_manufacturer — (manufacturer_id) (M018)
  • idx_products_active — (is_active, is_deleted) (M018)
  • idx_products_aim_u — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M130)

purchase_order_lines​

Introduced: M021. Columns: 22. Indexes: 5. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM021
purchase_order_idINTEGERnoFK → purchase_orders.idM021
line_numberINTEGERno1M021
variant_idINTEGERyesFK → product_variants.idM021
supplier_skuTEXTyesM021
descriptionTEXTyesM021
quantity_orderedINTEGERnoM021
quantity_receivedINTEGERno0M021
quantity_invoicedINTEGERno0M021
unit_cost_centsINTEGERno0M021
line_discount_centsINTEGERno0M021
line_total_centsINTEGERno0M021
expected_atTEXTyesM021
notesTEXTyesM021
is_special_orderINTEGERno0CHECK (is_special_order IN (0,1))M021
aim_idINTEGERyesM021
versionINTEGERno1M021
created_atTEXTnoCURRENT_TIMESTAMPM021
updated_atTEXTnoCURRENT_TIMESTAMPM021
special_order_transaction_idINTEGERyesFK → transactions.idM033
customer_idINTEGERyesFK → customers.idM037
earmarked_qtyINTEGERno0M037
Indexes:
  • idx_po_lines_po — (purchase_order_id) (M021)
  • idx_po_lines_variant — (variant_id) (M021)
  • idx_po_lines_special_order — (special_order_transaction_id) · WHERE special_order_transaction_id IS NOT NULL (M033)
  • idx_po_lines_customer — (customer_id) · WHERE customer_id IS NOT NULL (M037)
  • idx_po_lines_aim_u — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M130)

purchase_orders​

Introduced: M025. Columns: 24. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM025
po_numberTEXTnoM025
supplier_idINTEGERnoFK → suppliers.idM025
statusTEXTno'pending_order'CHECK (status IN ('pending_order','ordered'…M025
ordered_by_staff_idINTEGERyesFK → staff.idM025
ordered_atTEXTyesM025
expected_atTEXTyesM025
shipped_atTEXTyesM025
received_atTEXTyesM025
ship_methodTEXTyesM025
tracking_numberTEXTyesM025
shipping_cost_centsINTEGERyesM025
tax_centsINTEGERyesM025
subtotal_centsINTEGERyesM025
total_centsINTEGERyesM025
customer_idINTEGERyesFK → customers.idM025
notesTEXTyesM025
is_on_holdINTEGERno0CHECK (is_on_hold IN (0,1))M025
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M025
aim_idINTEGERyesM025
external_referenceTEXTyesM025
versionINTEGERno1M025
created_atTEXTnoCURRENT_TIMESTAMPM025
updated_atTEXTnoCURRENT_TIMESTAMPM025
Indexes:
  • idx_po_supplier — (supplier_id) (M025)
  • idx_po_status — (status, ordered_at DESC) (M025)

recovery_codes​

Introduced: M158. Columns: 7. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM158
code_hashTEXTnoM158
batchTEXTnoM158
created_atTEXTno(datetime('now')M158
created_by_staff_idINTEGERyesM158
used_atTEXTyesM158
used_ipTEXTyesM158

rental_addons​

Introduced: M102. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM102
nameTEXTnoM102
sort_orderINTEGERno0M102
default_givenINTEGERno0CHECK (default_given IN (0,1))M102
requires_refusal_initialsINTEGERno0CHECK (requires_refusal_initials IN (0,1))M102
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M102
created_atTEXTno(datetime('now')M102
updated_atTEXTno(datetime('now')M102
Indexes:
  • idx_rental_addons_live — (is_deleted, sort_order) (M102)

rental_booking_bikes​

Introduced: M070. Columns: 13. Indexes: 4. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM070
booking_idINTEGERnoM070
unit_idINTEGERnoM070
rate_centsINTEGERno0M070
out_atTEXTyesM071
returned_atTEXTyesM071
line_statusTEXTno'active'M082
added_atTEXTyesM082
removed_atTEXTyesM082
replaces_bike_idINTEGERyesFK → rental_booking_bikes.idM082
damage_captured_centsINTEGERno0M082
billed_unitsREALno1M082
line_centsINTEGERno0M082

Foreign keys (table-level):

  • booking_id → rental_bookings(id) (M070)
  • unit_id → inventory_units(id) (M070)

Indexes:

  • idx_rental_booking_bikes_unit — (unit_id) (M070)
  • idx_rental_booking_bikes_booking — (booking_id) (M070)
  • ix_rbb_active_unit — UNIQUE · (booking_id, unit_id) · WHERE line_status <> 'swapped_out' (M087)
  • ix_rbb_active_unit — UNIQUE · (booking_id, unit_id) · WHERE line_status NOT IN ('swapped_out','sold') (M088)

rental_booking_riders​

Introduced: M070. Columns: 5. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM070
booking_idINTEGERnoM070
nameTEXTnoM070
customer_idINTEGERyesFK → customers.idM082
is_minorINTEGERno0M082

Foreign keys (table-level):

  • booking_id → rental_bookings(id) (M070)

Indexes:

  • idx_rental_booking_riders_booking — (booking_id) (M070)

rental_bookings​

Introduced: M079. Columns: 40. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM079
location_idINTEGERno1M079
customer_idINTEGERnoM079
from_dateTEXTnoM079
to_dateTEXTnoM079
statusTEXTno'booked'CHECK (status IN ('booked','out','returned'…M079
subtotal_centsINTEGERno0M079
tax_centsINTEGERno0M079
total_centsINTEGERno0M079
notesTEXTyesM079
is_deletedINTEGERno0M079
versionINTEGERno1M079
created_atTEXTnoCURRENT_TIMESTAMPM079
updated_atTEXTnoCURRENT_TIMESTAMPM079
out_atTEXTyesM079
returned_atTEXTyesM079
deposit_transaction_idINTEGERyesFK → transactions.idM079
charge_transaction_idINTEGERyesFK → transactions.idM079
rate_basisTEXTno'daily'M079
start_timeTEXTyesM079
end_timeTEXTyesM079
halfday_windowTEXTyesM079
damage_hold_centsINTEGERyesM079
damage_hold_statusTEXTyesM079
damage_captured_centsINTEGERno0M079
no_show_atTEXTyesM079
no_show_reasonTEXTyesM079
cancelled_atTEXTyesM079
cancelled_reasonTEXTyesM079
lost_atTEXTyesM079
lost_reasonTEXTyesM079
extended_atTEXTyesM079
pickup_atTEXTyesM079
pickup_stateTEXTyesM079
reminder_sent_atTEXTyesM079
sourceTEXTno'counter'M079
damage_hold_auth_refTEXTyesM079
converted_sale_transaction_idINTEGERyesFK → transactions.idM079
damage_capture_transaction_idINTEGERyesFK → transactions.idM079
damage_hold_placed_atTEXTyesM098

Foreign keys (table-level):

  • customer_id → customers(id) (M079)

Indexes:

  • idx_rental_bookings_dates — (from_date, to_date) (M079)

rental_drafts​

Introduced: M099. Columns: 3. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
staff_idINTEGERyesPKM099
payloadTEXTnoM099
updated_atTEXTno(datetime('now')M099

rental_hold_policy​

Introduced: M097. Columns: 3. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
rental_categoryTEXTyesPKM097
hold_centsINTEGERno0M097
updated_atTEXTno(datetime('now')M097

rental_id_images​

Introduced: M096. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM096
mimeTEXTnoM096
dataTEXTnoM096
bytesINTEGERno0M096
uploaded_by_staff_idINTEGERyesFK → staff.idM096
created_atTEXTno(datetime('now')M096

rental_rate_cards​

Introduced: M119. Columns: 14. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM119
kindTEXTnoCHECK (kind IN ('rental','demo'))M119
category_keyTEXTnoM119
labelTEXTnoM119
session_minutesINTEGERyesM119
hourly_centsINTEGERyesM119
halfday_centsINTEGERyesM119
daily_centsINTEGERyesM119
weekly_centsINTEGERyesM119
damage_hold_centsINTEGERyesM119
sort_orderINTEGERno0M119
is_activeINTEGERno1CHECK (is_active IN (0,1))M119
created_atTEXTnoCURRENT_TIMESTAMPM119
updated_atTEXTnoCURRENT_TIMESTAMPM119
Indexes:
  • idx_rate_card_kind_cat — UNIQUE · (kind, category_key) (M119)

rental_waivers​

Introduced: M093. Columns: 24. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM093
booking_idINTEGERnoFK → rental_bookings.idM093
customer_idINTEGERyesFK → customers.idM093
signer_nameTEXTnoM093
is_main_contactINTEGERno0CHECK (is_main_contact IN (0,1))M093
is_minorINTEGERno0CHECK (is_minor IN (0,1))M093
guardian_nameTEXTyesM093
signature_pngTEXTnoM093
waiver_textTEXTnoM093
signed_atTEXTno(datetime('now')M093
witnessed_by_staff_idINTEGERyesFK → staff.idM093
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M093
public_tokenTEXTyesM094
id_typeTEXTyesM095
id_numberTEXTyesM095
id_dobTEXTyesM095
id_expiryTEXTyesM095
id_scanned_atTEXTyesM095
id_image_idINTEGERyesFK → rental_id_images.idM096
item_helmetINTEGERno1CHECK (item_helmet IN (0,1))M101
item_water_bottleINTEGERno0CHECK (item_water_bottle IN (0,1))M101
item_panniersINTEGERno0CHECK (item_panniers IN (0,1))M101
helmet_refused_initialsTEXTyesM101
items_jsonTEXTyesM102
Indexes:
  • idx_rental_waivers_booking — (booking_id) (M093)
  • idx_rental_waivers_customer — (customer_id) (M093)
  • idx_rental_waivers_token — UNIQUE · (public_token) (M094)

request_limits​

Introduced: M157. Columns: 4. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM157
actionTEXTnoM157
client_keyTEXTnoM157
occurred_atTEXTno(datetime('now')M157
Indexes:
  • idx_request_limits_key — (action, client_key, occurred_at) (M157)
  • idx_request_limits_time — (action, occurred_at) (M157)

rma​

Introduced: M024. Columns: 13. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM024
rma_numberTEXTnoM024
supplier_idINTEGERnoFK → suppliers.idM024
statusTEXTno'open'M024
reasonTEXTyesM024
resolutionTEXTyesM024
resolution_notesTEXTyesM024
created_by_staff_idINTEGERyesM024
shipped_atTEXTyesM024
resolved_atTEXTyesM024
is_deletedINTEGERno0M024
created_atTEXTno(datetime('now')M024
updated_atTEXTno(datetime('now')M024
Indexes:
  • idx_rma_supplier — (supplier_id, status, is_deleted) (M024)
  • idx_rma_status — (status, is_deleted) (M024)

rma_lines​

Introduced: M024. Columns: 7. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM024
rma_idINTEGERnoFK → rma.idM024
variant_idINTEGERnoFK → product_variants.idM024
quantityINTEGERnoM024
reasonTEXTyesM024
unit_cost_centsINTEGERyesM024
created_atTEXTno(datetime('now')M024
Indexes:
  • idx_rma_lines — (rma_id) (M024)

role_permissions​

Introduced: M008. Columns: 2. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
role_idINTEGERnoM008
permission_idINTEGERnoM008

Foreign keys (table-level):

  • role_id → roles(id) (M008)
  • permission_id → permissions(id) (M008)

roles​

Introduced: M008. Columns: 8. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM008
nameTEXTnoM008
display_nameTEXTnoM008
descriptionTEXTyesM008
is_systemINTEGERno0M008
created_atTEXTnoCURRENT_TIMESTAMPM008
updated_atTEXTnoCURRENT_TIMESTAMPM008
idle_lockout_secondsINTEGERyesCHECK (idle_lockout_seconds IS NULL OR idle…M008

search_synonym_groups​

Introduced: M010. Columns: 7. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM010
domainTEXTnoM010
descriptionTEXTyesM010
is_activeINTEGERno1M010
created_atTEXTnoCURRENT_TIMESTAMPM010
updated_atTEXTnoCURRENT_TIMESTAMPM010
created_by_staff_idINTEGERyesM010

Foreign keys (table-level):

  • created_by_staff_id → staff(id) (M010)

Indexes:

  • idx_search_synonym_groups_domain — (domain) · WHERE is_active = 1 (M010)

search_synonym_terms​

Introduced: M010. Columns: 5. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM010
group_idINTEGERnoM010
termTEXTnoM010
is_activeINTEGERno1M010
created_atTEXTnoCURRENT_TIMESTAMPM010

Foreign keys (table-level):

  • group_id → search_synonym_groups(id) (M010)

Unique (table-level):

  • (group_id, term) (M010)

Indexes:

  • idx_search_synonym_terms_group — (group_id) · WHERE is_active = 1 (M010)
  • idx_search_synonym_terms_term — (term) · WHERE is_active = 1 (M010)

service_bike_locations​

Introduced: M104. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM104
nameTEXTnoM104
sort_orderINTEGERno0M104
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M104
created_atTEXTno(datetime('now')M104
updated_atTEXTno(datetime('now')M104
Indexes:
  • idx_service_bike_locations_live — (is_deleted, sort_order) (M104)

service_menu​

Introduced: M030. Columns: 14. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM030
codeTEXTyesM030
nameTEXTnoM030
descriptionTEXTyesM030
categoryTEXTyesM030
price_centsINTEGERno0CHECK (price_cents >= 0)M030
est_minutesINTEGERyesM030
is_ebikeINTEGERno0CHECK (is_ebike IN (0,1))M030
tax_category_idINTEGERyesFK → tax_categories.idM030
sort_orderINTEGERno0M030
is_activeINTEGERno1CHECK (is_active IN (0,1))M030
aim_idINTEGERyesM030
created_atTEXTnoCURRENT_TIMESTAMPM030
updated_atTEXTnoCURRENT_TIMESTAMPM030
Indexes:
  • idx_service_menu_active — (is_active, sort_order) (M030)
  • idx_service_menu_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M141)

service_menu_parts​

Introduced: M145. Columns: 5. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM145
service_menu_idINTEGERnoFK → service_menu.idM145
variant_idINTEGERnoFK → product_variants.idM145
quantityINTEGERno1CHECK (quantity > 0)M145
created_atTEXTnoCURRENT_TIMESTAMPM145
Indexes:
  • uq_service_menu_parts — UNIQUE · (service_menu_id, variant_id) (M145)
  • idx_service_menu_parts_service — (service_menu_id) (M145)

service_signoffs​

Introduced: M112. Columns: 12. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM112
ticket_idINTEGERnoFK → service_tickets.idM112
kindTEXTnoCHECK (kind IN ('authorisation','pickup'))M112
customer_idINTEGERyesFK → customers.idM112
signer_nameTEXTnoM112
signature_pngTEXTnoM112
terms_textTEXTnoM112
budget_cents_at_signingINTEGERyesM112
total_cents_at_signingINTEGERyesM112
signed_atTEXTno(datetime('now')M112
witnessed_by_staff_idINTEGERyesFK → staff.idM112
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M112
Indexes:
  • idx_service_signoffs_ticket — (ticket_id, kind, is_deleted) (M112)

service_ticket_lines​

Introduced: M030. Columns: 25. Indexes: 4. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM030
ticket_idINTEGERnoFK → service_tickets.idM030
line_numberINTEGERno1M030
line_typeTEXTno'labour'CHECK (line_type IN ('labour','part'))M030
service_menu_idINTEGERyesFK → service_menu.idM030
variant_idINTEGERyesFK → product_variants.idM030
descriptionTEXTnoM030
skuTEXTyesM030
quantityINTEGERno1M030
unit_price_centsINTEGERno0M030
original_unit_price_centsINTEGERyesM030
labor_minutesINTEGERyesM030
discount_centsINTEGERno0M030
line_total_centsINTEGERno0M030
tax_category_idINTEGERyesFK → tax_categories.idM030
is_completedINTEGERno0CHECK (is_completed IN (0,1))M030
is_recommendedINTEGERno0CHECK (is_recommended IN (0,1))M030
assigned_mechanic_idINTEGERyesFK → staff.idM030
applied_discount_idINTEGERyesFK → discounts.idM030
created_atTEXTnoCURRENT_TIMESTAMPM030
aim_idINTEGERyesM038
parent_line_idINTEGERyesFK → service_ticket_lines.idM110
discount_reasonTEXTyesM151
special_orderINTEGERno0M152
so_touchedINTEGERno0M152
Indexes:
  • idx_stl_ticket — (ticket_id) (M030)
  • idx_stl_variant — (variant_id) (M030)
  • idx_svc_lines_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)
  • idx_stl_parent — (parent_line_id) (M110)

service_ticket_messages​

Introduced: M030. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM030
ticket_idINTEGERnoFK → service_tickets.idM030
directionTEXTno'outbound'CHECK (direction IN ('outbound','inbound'))M030
channelTEXTno'sms'CHECK (channel IN ('sms','email','phone_cal…M030
message_textTEXTnoM030
sent_by_staff_idINTEGERyesFK → staff.idM030
delivery_statusTEXTno'recorded'M030
created_atTEXTnoCURRENT_TIMESTAMPM030
Indexes:
  • idx_stm_ticket — (ticket_id, created_at) (M030)

service_ticket_status_history​

Introduced: M030. Columns: 8. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM030
ticket_idINTEGERnoFK → service_tickets.idM030
from_statusTEXTyesM030
to_statusTEXTnoM030
staff_idINTEGERyesFK → staff.idM030
reasonTEXTyesM030
created_atTEXTnoCURRENT_TIMESTAMPM030
aim_idINTEGERyesM038
Indexes:
  • idx_sth_ticket — (ticket_id, created_at) (M030)
  • idx_svc_stathist_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

service_tickets​

Introduced: M030. Columns: 50. Indexes: 5. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM030
ticket_numberTEXTnoM030
customer_idINTEGERyesFK → customers.idM030
bill_to_customer_idINTEGERyesFK → customers.idM030
customer_bike_idINTEGERyesFK → customer_bikes.idM030
bike_descriptionTEXTyesM030
bike_serialTEXTyesM030
bike_locationTEXTyesM030
statusTEXTno'dropped_off'M030
urgencyTEXTno'normal'M030
urgency_notesTEXTyesM030
primary_mechanic_idINTEGERyesFK → staff.idM030
reported_issuesTEXTyesM030
mechanic_findingsTEXTyesM030
staff_notesTEXTyesM030
dropped_off_atTEXTnoCURRENT_TIMESTAMPM030
promised_atTEXTyesM030
estimated_atTEXTyesM030
estimate_amount_centsINTEGERyesM030
estimate_approved_atTEXTyesM030
work_started_atTEXTyesM030
ready_atTEXTyesM030
notified_atTEXTyesM030
picked_up_atTEXTyesM030
paid_in_full_atTEXTyesM030
warranty_untilTEXTyesM030
cancelled_atTEXTyesM030
cancelled_reasonTEXTyesM030
hold_reasonTEXTyesM030
total_labor_minutesINTEGERno0M030
labour_centsINTEGERno0M030
parts_centsINTEGERno0M030
subtotal_centsINTEGERno0M030
discount_centsINTEGERno0M030
gst_centsINTEGERno0M030
pst_centsINTEGERno0M030
total_centsINTEGERno0M030
deposit_centsINTEGERno0M030
service_discount_idINTEGERyesFK → discounts.idM030
invoice_transaction_idINTEGERyesFK → transactions.idM030
created_by_staff_idINTEGERyesFK → staff.idM030
created_atTEXTnoCURRENT_TIMESTAMPM030
updated_atTEXTnoCURRENT_TIMESTAMPM030
aim_idINTEGERyesM038
inventory_unit_idINTEGERyesFK → inventory_units.idM085
rental_booking_idINTEGERyesFK → rental_bookings.idM085
is_internalINTEGERno0M085
parts_vendorTEXTyesM109
parts_etaTEXTyesM109
max_budget_centsINTEGERyesM142
Indexes:
  • idx_tickets_customer — (customer_id) (M030)
  • idx_tickets_status — (status, dropped_off_at DESC) (M030)
  • idx_tickets_bike — (customer_bike_id) (M030)
  • idx_tickets_mechanic — (primary_mechanic_id) (M030)
  • idx_svc_tickets_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

service_urgency_levels​

Introduced: M104. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM104
nameTEXTnoM104
sort_orderINTEGERno0M104
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M104
created_atTEXTno(datetime('now')M104
updated_atTEXTno(datetime('now')M104
Indexes:
  • idx_service_urgency_levels_live — (is_deleted, sort_order) (M104)

session_devices​

Introduced: M160. Columns: 2. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
tokenTEXTyesPKM160
device_keyTEXTnoM160
Indexes:
  • idx_session_devices_key — (device_key) (M160)

sessions​

Introduced: M001. Columns: 4. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
tokenTEXTyesPKM001
staff_idINTEGERnoFK → staff.idM001
created_atTEXTno(datetime('now')M001
expires_atTEXTnoM001
Indexes:
  • idx_sessions_staff — (staff_id) (M001)

shop_announcements​

Introduced: M144. Columns: 11. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM144
posted_by_staff_idINTEGERnoFK → staff.idM144
bodyTEXTnoM144
pinnedINTEGERno0CHECK (pinned IN (0,1))M144
posted_atTEXTnoCURRENT_TIMESTAMPM144
expires_atTEXTyesM144
edited_atTEXTyesM144
retired_atTEXTyesM144
retired_by_staff_idINTEGERyesFK → staff.idM144
is_activeINTEGERno1CHECK (is_active IN (0,1))M144
versionINTEGERno1M144

Checks (table-level):

  • (length(body) BETWEEN 1 AND 100000) (M144)

Indexes:

  • idx_shop_announcements_feed — (pinned DESC, posted_at DESC) · WHERE is_active = 1 (M144)

shop_config​

Introduced: M035. Columns: 64. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPK · CHECK (id = 1)M035
business_nameTEXTnoM035
legal_nameTEXTyesM035
address_line_1TEXTnoM035
address_line_2TEXTyesM035
cityTEXTnoM035
provinceTEXTno'BC'M035
postal_codeTEXTnoM035
countryTEXTno'CA'M035
phone_primaryTEXTnoM035
email_primaryTEXTnoM035
website_urlTEXTyesM035
gst_numberTEXTyesM035
pst_numberTEXTyesM035
fiscal_year_end_mmddTEXTno'12-31'M035
hours_jsonTEXTno'{}'M035
receipt_footer_textTEXTyesM035
receipt_logo_urlTEXTyesM035
versionINTEGERno1M035
created_atTEXTno(datetime('now')M035
updated_atTEXTno(datetime('now')M035
layaway_term_daysINTEGERno90M036
tab_accents_jsonTEXTyesM042
gift_cards_enabledINTEGERno1CHECK (gift_cards_enabled IN (0, 1))M045
account_credit_enabledINTEGERno1CHECK (account_credit_enabled IN (0, 1))M045
pos_tender_mc_enabledINTEGERno1CHECK (pos_tender_mc_enabled IN (0,1))M056
pos_tender_visa_enabledINTEGERno1CHECK (pos_tender_visa_enabled IN (0,1))M056
pos_tender_debit_enabledINTEGERno1CHECK (pos_tender_debit_enabled IN (0,1))M056
pos_tender_cash_enabledINTEGERno1CHECK (pos_tender_cash_enabled IN (0,1))M056
pos_tender_card_manual_enabledINTEGERno1CHECK (pos_tender_card_manual_enabled IN (0…M056
pos_tender_store_credit_enabledINTEGERno1CHECK (pos_tender_store_credit_enabled IN (…M056
pos_tender_check_enabledINTEGERno1CHECK (pos_tender_check_enabled IN (0,1))M056
pos_tender_etransfer_enabledINTEGERno1CHECK (pos_tender_etransfer_enabled IN (0,1))M056
pos_tender_promo_enabledINTEGERno1CHECK (pos_tender_promo_enabled IN (0,1))M056
pos_layaway_enabledINTEGERno1CHECK (pos_layaway_enabled IN (0,1))M057
rental_deposit_pctINTEGERno50CHECK (rental_deposit_pct BETWEEN 0 AND 100)M073
rental_late_fee_enabledINTEGERno1CHECK (rental_late_fee_enabled IN (0,1))M086
rental_late_grace_minutesINTEGERno30CHECK (rental_late_grace_minutes BETWEEN 0 …M086
rental_daycount_basisTEXTno'inclusive'CHECK (rental_daycount_basis IN ('inclusive…M089
rental_min_daysINTEGERno1CHECK (rental_min_days BETWEEN 1 AND 60)M089
rental_min_charge_centsINTEGERno0CHECK (rental_min_charge_cents >= 0)M089
rental_early_return_policyTEXTno'no_refund'CHECK (rental_early_return_policy IN ('no_r…M089
rental_early_return_fee_centsINTEGERno0CHECK (rental_early_return_fee_cents >= 0)M089
rental_early_return_cutoffTEXTyesM089
rental_cancel_policyTEXTno'full_refund'CHECK (rental_cancel_policy IN ('full_refun…M089
rental_cancel_fee_centsINTEGERno0CHECK (rental_cancel_fee_cents >= 0)M089
rental_cancel_window_hoursINTEGERno0CHECK (rental_cancel_window_hours BETWEEN 0…M089
rental_waiver_textTEXTyesM097
rental_hold_default_centsINTEGERno0M097
rental_deposit_pct_dayofINTEGERyesM100
rental_deposit_pct_futureINTEGERyesM100
service_bench_mechanicsINTEGERno1M108
service_bench_minutes_per_dayINTEGERno360M108
service_parts_hold_keeps_slotINTEGERno0M108
service_authorisation_textTEXTyesM112
service_pickup_textTEXTyesM112
service_require_signoffINTEGERno0M112
service_default_interval_daysINTEGERno365M114
loyalty_enabledINTEGERno0M116
loyalty_points_per_dollarINTEGERno1M116
loyalty_cents_per_pointINTEGERno1M116
service_max_budget_enabledINTEGERno1M150
demo_modeINTEGERno0M155
require_morning_unlockINTEGERno0M158

shop_note_comments​

Introduced: M148. Columns: 6. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM148
note_idINTEGERnoM148
author_staff_idINTEGERnoM148
body_htmlTEXTno''M148
created_atTEXTnoCURRENT_TIMESTAMPM148
updated_atTEXTnoCURRENT_TIMESTAMPM148
Indexes:
  • idx_note_comments_note — (note_id, created_at ASC) (M148)

shop_note_reads​

Introduced: M149. Columns: 3. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
note_idINTEGERnoM149
staff_idINTEGERnoM149
read_atTEXTnoCURRENT_TIMESTAMPM149
Indexes:
  • idx_note_reads_staff — (staff_id, note_id) (M149)

shop_notes​

Introduced: M127. Columns: 11. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM127
author_staff_idINTEGERnoM127
body_htmlTEXTno''M127
created_atTEXTnoCURRENT_TIMESTAMPM127
updated_atTEXTnoCURRENT_TIMESTAMPM127
tabTEXTno'general'M128
statusTEXTno'open'M147
resolution_htmlTEXTno''M147
resolved_atTEXTyesM147
resolved_by_staff_idINTEGERyesM147
fixed_in_versionTEXTno''M147
Indexes:
  • idx_shop_notes_created — (created_at DESC) (M127)
  • idx_shop_notes_tab — (tab, created_at DESC) (M128)
  • idx_shop_notes_tab_status — (tab, status, created_at DESC) (M147)

signin_devices​

Introduced: M160. Columns: 5. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM160
token_hashTEXTnoCHECK (length(token_hash) = 64)M160
codeTEXTnoCHECK (length(code) = 4)M160
first_ipTEXTyesM160
created_atTEXTno(datetime('now')M160

signin_lockouts​

Introduced: M160. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM160
client_keyTEXTnoM160
codeTEXTyesM160
wrong_pinsINTEGERnoCHECK (wrong_pins >= 1)M160
last_ipTEXTyesM160
locked_atTEXTno(datetime('now')M160
cleared_atTEXTyesM160
cleared_byTEXTyesM160

Checks (table-level):

  • ((cleared_at IS NULL) = (cleared_by IS NULL)) (M160)

Indexes:

  • idx_signin_lockouts_open — UNIQUE · (client_key) · WHERE cleared_at IS NULL (M160)

staff​

Introduced: M001. Columns: 18. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM001
nameTEXTnoM001
roleTEXTno'staff'M001
pin_hashTEXTyesM001
pin_saltTEXTyesM001
activeINTEGERno1M001
created_atTEXTno(datetime('now')M001
role_idINTEGERyesFK → roles.idM008
initialsTEXTyesM009
emailTEXTyesM009
phone_mobileTEXTyesM009
idle_lockout_secondsINTEGERyesCHECK (idle_lockout_seconds IS NULL OR idle…M009
override_role_idINTEGERyesFK → roles.idM016
external_aim_idINTEGERyesM034
start_dateTEXTyesM034
usernameTEXTyesM034
tooltip_modeTEXTno'heuristic'CHECK (tooltip_mode IN ('on', 'off', 'heuri…M043
can_access_notesINTEGERno0M127
Indexes:
  • idx_staff_external_aim — (external_aim_id) (M034)

staff_duties​

Introduced: M144. Columns: 17. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM144
assigned_to_staff_idINTEGERyesFK → staff.idM144
created_by_staff_idINTEGERnoFK → staff.idM144
titleTEXTnoM144
bodyTEXTyesM144
shift_dateTEXTyesM144
statusTEXTno'pending'CHECK (status IN ('pending','in_progress','…M144
completed_atTEXTyesM144
completed_by_staff_idINTEGERyesFK → staff.idM144
template_idINTEGERyesFK → duty_templates.idM144
sourceTEXTno'adhoc'CHECK (source IN ('adhoc','template'))M144
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M144
deleted_atTEXTyesM144
deleted_by_staff_idINTEGERyesFK → staff.idM144
versionINTEGERno1M144
created_atTEXTnoCURRENT_TIMESTAMPM144
updated_atTEXTnoCURRENT_TIMESTAMPM144

Checks (table-level):

  • (length(title) BETWEEN 1 AND 200) (M144)
  • (body IS NULL OR length(body) <= 4000) (M144)

Indexes:

  • idx_staff_duties_date — (shift_date) · WHERE is_deleted = 0 (M144)
  • idx_staff_duties_assignee — (assigned_to_staff_id, shift_date) · WHERE is_deleted = 0 (M144)
  • uq_staff_duties_template_day — UNIQUE · (template_id, shift_date) · WHERE template_id IS NOT NULL (M144)

staff_feature_state​

Introduced: M043. Columns: 8. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
staff_idINTEGERnoFK → staff.idM043
feature_keyTEXTnoM043
use_countINTEGERno0CHECK (use_count >= 0)M043
first_used_atINTEGERyesM043
last_used_atINTEGERyesM043
tooltip_force_showINTEGERno0CHECK (tooltip_force_show IN (0, 1))M043
created_atINTEGERno(unixepoch()M043
updated_atINTEGERno(unixepoch()M043
Indexes:
  • idx_sfs_staff — (staff_id) (M043)

staff_messages​

Introduced: M144. Columns: 7. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM144
from_staff_idINTEGERnoFK → staff.idM144
to_staff_idINTEGERnoFK → staff.idM144
bodyTEXTnoM144
created_atTEXTnoCURRENT_TIMESTAMPM144
read_atTEXTyesM144
is_deletedINTEGERno0CHECK (is_deleted IN (0,1))M144

Checks (table-level):

  • (from_staff_id != to_staff_id) (M144)
  • (length(body) BETWEEN 1 AND 4000) (M144)

Indexes:

  • idx_staff_messages_to — (to_staff_id, created_at DESC) · WHERE is_deleted = 0 (M144)
  • idx_staff_messages_from — (from_staff_id, created_at DESC) · WHERE is_deleted = 0 (M144)

staff_permission_overrides​

Introduced: M008. Columns: 8. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM008
staff_idINTEGERnoM008
permission_idINTEGERnoM008
allowINTEGERnoM008
reasonTEXTyesM008
granted_by_staff_idINTEGERyesM008
granted_atTEXTnoCURRENT_TIMESTAMPM008
expires_atTEXTyesM008

Foreign keys (table-level):

  • staff_id → staff(id) (M008)
  • permission_id → permissions(id) (M008)
  • granted_by_staff_id → staff(id) (M008)

Unique (table-level):

  • (staff_id, permission_id) (M008)

staff_screen_permissions​

Introduced: M008. Columns: 3. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
staff_idINTEGERnoM008
permission_idINTEGERnoM008
granted_atTEXTnoCURRENT_TIMESTAMPM008

Foreign keys (table-level):

  • staff_id → staff(id) (M008)
  • permission_id → permissions(id) (M008)

subcategories​

Introduced: M018. Columns: 12. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
category_idINTEGERnoFK → categories.idM018
codeTEXTyesM018
nameTEXTnoM018
descriptionTEXTyesM018
display_orderINTEGERno0M018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
aim_idINTEGERyesM018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018
default_tax_category_idINTEGERyesFK → tax_categories.idM055
parent_subcategory_idINTEGERyesFK → subcategories.idM153
Indexes:
  • idx_subcategories_category — (category_id) (M018)
  • idx_subcategories_cat_code_u — UNIQUE · (category_id, code) · WHERE code IS NOT NULL (M130)
  • idx_subcategories_parent — (parent_subcategory_id) (M153)

supplier_products​

Introduced: M020. Columns: 12. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM020
supplier_idINTEGERnoFK → suppliers.idM020
variant_idINTEGERnoFK → product_variants.idM020
supplier_skuTEXTyesM020
cost_centsINTEGERyesM020
next_cost_centsINTEGERyesM020
is_primary_supplierINTEGERno0CHECK (is_primary_supplier IN (0,1))M020
last_received_atTEXTyesM020
is_activeINTEGERno1CHECK (is_active IN (0,1))M020
aim_idINTEGERyesM020
created_atTEXTnoCURRENT_TIMESTAMPM020
updated_atTEXTnoCURRENT_TIMESTAMPM020

Unique (table-level):

  • (supplier_id, variant_id) (M020)

Indexes:

  • idx_supplier_products_variant — (variant_id) (M020)
  • idx_supplier_products_supplier — (supplier_id) (M020)
  • idx_supplier_products_primary — (variant_id, is_primary_supplier) (M020)

suppliers​

Introduced: M020. Columns: 22. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM020
nameTEXTnoM020
display_nameTEXTyesM020
account_numberTEXTyesM020
contact_nameTEXTyesM020
contact_phoneTEXTyesM020
contact_emailTEXTyesM020
contact_addressTEXTyesM020
website_urlTEXTyesM020
b2b_portal_urlTEXTyesM020
payment_termsTEXTyesM020
default_lead_time_daysINTEGERyesM020
is_drop_ship_capableINTEGERno0CHECK (is_drop_ship_capable IN (0,1))M020
display_color_hexTEXTyesM020
logo_urlTEXTyesM020
notesTEXTyesM020
is_activeINTEGERno1CHECK (is_active IN (0,1))M020
aim_idINTEGERyesM020
versionINTEGERno1M020
created_atTEXTnoCURRENT_TIMESTAMPM020
updated_atTEXTnoCURRENT_TIMESTAMPM020
name_keyTEXTyesM062
Indexes:
  • idx_suppliers_name_key_active — UNIQUE · (name_key) · WHERE is_active = 1 (M062)

tags​

Introduced: M003. Columns: 6. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM003
nameTEXTnoM003
color_hexTEXTyesM003
descriptionTEXTyesM003
is_systemINTEGERno0M003
created_atTEXTnoCURRENT_TIMESTAMPM003

tax_categories​

Introduced: M018. Columns: 12. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
nameTEXTnoM018
display_nameTEXTnoM018
descriptionTEXTyesM018
applies_gstINTEGERno1CHECK (applies_gst IN (0,1))M018
applies_pstINTEGERno1CHECK (applies_pst IN (0,1))M018
is_context_dependentINTEGERno0CHECK (is_context_dependent IN (0,1))M018
context_ruleTEXTyesM018
legal_referenceTEXTyesM018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
created_atTEXTnoCURRENT_TIMESTAMPM018
updated_atTEXTnoCURRENT_TIMESTAMPM018

tax_rates​

Introduced: M018. Columns: 10. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM018
nameTEXTnoM018
display_nameTEXTnoM018
rate_basis_pointsINTEGERnoM018
jurisdictionTEXTyesM018
applies_toTEXTnoCHECK (applies_to IN ('gst','pst'))M018
effective_fromTEXTyesM018
effective_untilTEXTyesM018
is_activeINTEGERno1CHECK (is_active IN (0,1))M018
created_atTEXTnoCURRENT_TIMESTAMPM018

transaction_discounts​

Introduced: M027. Columns: 9. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
transaction_idINTEGERnoFK → transactions.idM027
discount_typeTEXTnoM027
descriptionTEXTyesM027
amount_centsINTEGERnoM027
applied_by_staff_idINTEGERyesFK → staff.idM027
created_atTEXTnoCURRENT_TIMESTAMPM027
transaction_line_idINTEGERyesM028
discount_idINTEGERyesM028
Indexes:
  • idx_txn_disc_txn — (transaction_id) (M027)
  • idx_txn_discounts_line — (transaction_line_id) (M028)

transaction_lines​

Introduced: M027. Columns: 24. Indexes: 3. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
transaction_idINTEGERnoFK → transactions.idM027
line_numberINTEGERno1M027
variant_idINTEGERyesFK → product_variants.idM027
descriptionTEXTnoM027
skuTEXTyesM027
manufacturer_nameTEXTyesM027
modelTEXTyesM027
quantityINTEGERno1M027
unit_price_centsINTEGERno0M027
original_unit_price_centsINTEGERyesM027
cost_at_sale_centsINTEGERyesM027
discount_centsINTEGERno0M027
line_total_centsINTEGERno0M027
tax_category_idINTEGERyesFK → tax_categories.idM027
serial_numberTEXTyesM027
is_voidedINTEGERno0CHECK (is_voided IN (0,1))M027
refunded_quantityINTEGERno0M027
created_atTEXTnoCURRENT_TIMESTAMPM027
return_conditionTEXTyesM029
aim_idINTEGERyesM038
account_credit_customer_idINTEGERyesM046
fitted_to_bikeINTEGERno0M050
rental_unit_idINTEGERyesFK → inventory_units.idM072
Indexes:
  • idx_txn_lines_txn — (transaction_id) (M027)
  • idx_txn_lines_variant — (variant_id) (M027)
  • idx_tx_lines_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

transaction_taxes​

Introduced: M027. Columns: 7. Indexes: 2. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM027
transaction_idINTEGERnoFK → transactions.idM027
tax_nameTEXTnoM027
rate_basis_pointsINTEGERnoM027
taxable_amount_centsINTEGERnoM027
tax_amount_centsINTEGERnoM027
created_atTEXTnoCURRENT_TIMESTAMPM027
Indexes:
  • idx_txn_taxes_txn — (transaction_id) (M027)
  • idx_txn_taxes_txn_name_u — UNIQUE · (transaction_id, tax_name) (M135)

transactions​

Introduced: M004. Columns: 34. Indexes: 6. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM004
reference_numberTEXTyesM004
transaction_typeTEXTno'sale'M004
customer_idINTEGERyesM004
occurred_atTEXTnoCURRENT_TIMESTAMPM004
subtotal_centsINTEGERno0M004
total_centsINTEGERno0M004
amount_received_centsINTEGERno0M004
statusTEXTno'posted'M004
staff_idINTEGERyesM004
staff_initialsTEXTyesM004
related_ticket_idINTEGERyesM004
created_atTEXTnoCURRENT_TIMESTAMPM004
total_tax_centsINTEGERno0M027
total_discount_centsINTEGERno0M027
amount_outstanding_centsINTEGERno0M027
posted_atTEXTyesM027
voided_atTEXTyesM027
voided_by_staff_idINTEGERyesM027
void_reasonTEXTyesM027
related_transaction_idINTEGERyesM027
tax_exempt_status_card_numberTEXTyesM027
tax_override_reasonTEXTyesM027
notesTEXTyesM027
updated_atTEXTyesM027
restocking_fee_centsINTEGERno0M029
return_reasonTEXTyesM029
deposit_kindTEXTyesM036
deposit_statusTEXTyesM036
settled_transaction_idINTEGERyesFK → transactions.idM036
is_price_lockedINTEGERno1M036
quoted_atTEXTyesM036
aim_idINTEGERyesM038
rental_booking_idINTEGERyesFK → rental_bookings.idM072
Indexes:
  • idx_tx_customer — (customer_id, occurred_at DESC) (M004)
  • idx_tx_occurred — (occurred_at DESC) (M004)
  • idx_txn_customer_occurred — (customer_id, occurred_at, id) (M006)
  • idx_txn_occurred — (occurred_at, id) (M006)
  • idx_tx_deposit_status — (deposit_status) · WHERE deposit_status IS NOT NULL (M036)
  • idx_transactions_aim — UNIQUE · (aim_id) · WHERE aim_id IS NOT NULL (M038)

unlock_accounts​

Introduced: M158. Columns: 9. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM158
google_emailTEXTnoM158
google_subTEXTyesM158
staff_idINTEGERyesM158
phoneTEXTnoM158
activeINTEGERno1M158
created_atTEXTno(datetime('now')M158
created_by_staff_idINTEGERyesM158
last_unlock_atTEXTyesM158

unlock_codes​

Introduced: M158. Columns: 7. Indexes: 0. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idTEXTyesPKM158
account_idINTEGERnoM158
code_hashTEXTnoM158
attemptsINTEGERno0M158
created_atTEXTno(datetime('now')M158
expires_atTEXTnoM158
used_atTEXTyesM158

website_content​

Introduced: M122. Columns: 7. Indexes: 1. Triggers: 0.

ColumnTypeNullDefaultConstraintsSince
idINTEGERyesPKM122
pageTEXTnoM122
blockTEXTnoM122
htmlTEXTnoM122
originalTEXTyesM122
updated_byINTEGERyesFK → staff.idM122
updated_atTEXTnoCURRENT_TIMESTAMPM122

Unique (table-level):

  • (page, block) (M122)

Indexes:

  • idx_website_content_page — (page) (M122)