Orders table

The Orders table in the FitStack - V2 schema has 23 columns, keyed by Id, with 5 foreign keys to Companies, Gyms, GymClients, Employees and 1 more. 2 columns in GymStockMovements and OrderLines reference it.

One sale. Glossary: Order; a Draft Order is the cart.

Columns (23)

Columns of the Orders table
ColumnTypeConstraintsDescription
Iduuidprimary key, not null
CompanyIduuidnot null, references Companies.Id
GymIduuidnot null, references Gyms.IdWhere it was sold or collected.
MemberIduuidreferences GymClients.IdNull for a walk-in paying cash or by Terminal.
EmployeeIduuidreferences Employees.IdWho rang it up; null for App/Web.
Numbercharacter varying(32)not nullHuman-readable, per Company.
Statustextnot null`OrderStatus`.
Channeltextnot null`OrderChannel`.
PaymentMethodtext`OrderPaymentMethod`. Null while Draft.
SubtotalCentsintegernot null
TaxCentsintegernot null
TotalCentsintegernot null
PlatformFeeCentsintegernot null
Currencycharacter varying(3)not null
StripePaymentIntentIdtext
StripeTaxCalculationIdtext
StripeTerminalReaderIduuidreferences StripeTerminalReaders.Id
PaidAttimestamp with time zone
RefundedCentsintegernot null
CreatedAttimestamp with time zonenot null
ModifiedAttimestamp with time zone
IsDeletedbooleannot null
DeletedAttimestamp with time zone

Indexes (4)

  • (CompanyId, Number) unique (IX_Orders_CompanyId_Number)
  • (GymId, PaidAt) (IX_Orders_GymId_PaidAt)
  • (MemberId, CreatedAt) (IX_Orders_MemberId_CreatedAt)
  • (StripePaymentIntentId) (IX_Orders_StripePaymentIntentId)

Relationships