Database Schema
Understanding the Data Models.
RetailCoder uses Prisma ORM. Below are the core models you will interact with if building custom SQL queries or extensions.
Order Model#
The central entity. Contains billing/shipping info and JSON snapshots of the address at the time of purchase.
prisma
model Order {
id String @id @default(uuid())
orderNumber String @unique
status OrderStatus
paymentStatus PaymentStatus
totalAmount Decimal
items OrderItem[]
customer Customer @relation(...)
organizationId String
}Inventory Ledger#
The immutable audit log. Never delete rows from this table.
prisma
model InventoryLedger {
id String @id @default(uuid())
variantId String
storeId String
quantity Int // Positive (IN) or Negative (OUT)
balanceAfter Int
refType String // e.g., "ORDER", "PO", "RETURN"
refId String // The ID of the Order/PO
}