Database
All tables are created automatically on first start. The script includes an auto-migration system that adds new columns when upgrading.
Tables
code9_shop_settings
Main shop configuration table.
| Column | Type | Default | Description |
|---|---|---|---|
shopId | INT (PK, AI) | Unique shop identifier | |
creatorLicense | VARCHAR(255) | License of the shop creator | |
shopName | VARCHAR(255) | Internal shop name | |
shopLabel | VARCHAR(255) | Display label | |
job | VARCHAR(50) | 'all' | Required job ('all' for none) |
blip | TEXT | Blip settings (JSON) | |
ped | TEXT | Ped settings (JSON) | |
interactCoords | TEXT | Legacy interaction coordinates | |
theme | TEXT | Theme settings (JSON) | |
interactionDistance | FLOAT | NULL | Shop-level interaction distance |
webhook | TEXT | NULL | Webhook settings (JSON) |
createdAt | TIMESTAMP | CURRENT | Creation timestamp |
code9_shop_stocks
Products/items for each shop.
| Column | Type | Default | Description |
|---|---|---|---|
id | INT (PK, AI) | Unique product identifier | |
shopId | INT | Parent shop ID | |
itemName | VARCHAR(255) | Inventory item code | |
name | VARCHAR(255) | Display name | |
image | TEXT | Image URL | |
price | DECIMAL(10,2) | Item price | |
category | VARCHAR(100) | Category assignment | |
description | TEXT | Item description | |
isStock | TINYINT(1) | 0 | Stock tracking enabled |
stock | INT | 0 | Current stock amount |
jobGrade | INT | 0 | Minimum job grade required |
itemJob | VARCHAR(50) | '' | Required job for this item |
createdAt | TIMESTAMP | CURRENT | Creation timestamp |
code9_shop_category
Categories for each shop.
| Column | Type | Default | Description |
|---|---|---|---|
id | VARCHAR(100) | Category ID (composite PK) | |
shopId | INT | Parent shop ID (composite PK) | |
name | VARCHAR(255) | Category name | |
image | TEXT | Category image URL | |
createdAt | TIMESTAMP | CURRENT | Creation timestamp |
code9_shop_locations
Multi-location support table.
| Column | Type | Default | Description |
|---|---|---|---|
locationId | INT (PK, AI) | Unique location identifier | |
shopId | INT (indexed) | Parent shop ID | |
locationName | VARCHAR(255) | Location display name | |
interactCoords | TEXT | Interaction coordinates (JSON) | |
blip | TEXT | Blip settings (JSON) | |
ped | TEXT | Ped settings (JSON) | |
enabled | TINYINT(1) | 1 | Location enabled state |
interactionDistance | FLOAT | NULL | Per-location interaction distance |
createdAt | TIMESTAMP | CURRENT | Creation timestamp |
Auto-Migration
The script automatically handles schema changes:
- New columns are added to existing tables without data loss
- Legacy single-location shops are migrated to the
code9_shop_locationstable - No manual SQL is needed when upgrading
Cascading Delete
When a shop is deleted, all related data is removed in order:
code9_shop_stocks(products)code9_shop_category(categories)code9_shop_locations(locations)code9_shop_settings(shop itself)
