Skip to content
Rohit Patil edited this page Nov 8, 2024 · 7 revisions

Database Schema

Table Users {
  id uuid [primary key]
  firstName varchar [not null]
  lastName varchar 
  email varchar [not null, unique]
  emailVerified bool [default: false]
  mobile varchar [not null, unique]
  mobileVerified bool [default: false]
  googleId varchar [unique]
  role UserRole
  lastLogout timestamp
  createdAt timestamp
  updatedAt timestamp
}

Table HashedPassword {
  id uuid
  userId uuid [ref: - Users.id]
  hashedPassword varchar
}

Enum UserRole {
  CUSTOMER
  SUPER_ADMIN
}

Table Merchant {
  id uuid [primary key]
  restaurantName varchar
  address uuid [not null, ref: - Address.id]
  owner uuid [not null, ref: > Users.id]
  type MerchantType [not null,  default: "DINE_IN"]
  isOnline bool [default: false]
  createdAt timestamp
  updatedAt timestamp
}

Table MerchantManagers {
  id uuid [primary key]
  userId uuid [not null, ref: - Users.id]
  merchantId uuid [not null, ref: > Merchant.id]
  role MechantRole
}

Enum MerchantRole {
  MERCHANT_ADMIN
  MERCHANT_OPERATOR
  MERCHANT_OWNER
}

Table Timing {
  id uuid [primary key]
  merchantId uuid [not null, ref: > Merchant.id]
  dayOfWeek DayOfWeek [not null]
  openTime time
  closeTime time
  isClosed bool [default: false]
  createdAt timestamp
  updatedAt timestamp

  indexes {
    (merchantId, dayOfWeek) [unique]
  }
}

Enum DayOfWeek {
  MONDAY
  TUESDAY
  WEDNESDAY
  THURSDAY
  FRIDAY
  SATURDAY
  SUNDAY
}

Table Address {
  id uuid [primary key]
  addressLine1 varchar [not null]
  addressLine2 varchar
  city varchar
  district varchar
  state varchar
  pincode varchar(6)
  createdAt timestamp
  updatedAt timestamp
}

Table MenuCategory{
  id uuid [primary key]
  name varchar [not null]
  merchantId uuid [not null, ref : > Merchant.id]
  createdAt timestamp
  updatedAt timestamp
}

Table MenuItem {
  id uuid [primary key]
  merchantId uuid [not null, ref: > Merchant.id]
  name varchar [not null]
  description varchar
  category uuid [not null, ref: > MenuCategory.id]
  tag ItemTag [not null]
  price float [not null]
  imageUrl varchar
  createdAt timestamp
  updatedAt timestamp
}

Enum MerchantType{
  DINE_IN
  TAKE_AWAY
}

Enum ItemTag {
  VEG
  NONVEG
  JAIN
}

Table Table {
  id uuid [primary key]
  merchantId uuid [not null, ref: > Merchant.id]
  tableNumber int [not null]
  createdAt timestamp
  updatedAt timestamp

  indexes {
    (merchantId, tableNumber) [unique]
  }
}

Table QrCode {
  id uuid [primary key]
  tableId uuid [ref: - Table.id]
  merchantId uuid [not null, ref: > Merchant.id]
  createdAt timestamp
  updatedAt timestamp
}

Table Order {
  id uuid [primary key]
  token integer
  merchantId uuid [not null, ref: > Merchant.id]
  tableId uuid [ref: > Table.id]
  status OrderStatus [default: 'ACCEPTED']
  totalAmout float
  createdAt timestamp
  updatedAt timestamp
}

Table OrderItem {
  id uuid [primary key]
  itemId uuid [not null, ref: > MenuItem.id]
  orderId uuid [not null, ref: > Order.id]
  instruction varchar 
  quantity int
  amount float
  status OrderItemStatus [default: 'PREPARING']
  createdAt timestamp
}

Enum OrderStatus{
  ACCEPTED
  PREPARING
  COMPLETED
}

Enum OrderItemStatus {
  PREPARING
  SERVED
}

Why to wait - Database Schema

Clone this wiki locally