-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Rohit Patil edited this page Nov 15, 2024
·
7 revisions
Table users {
id uuid [primary key]
first_name varchar [not null]
last_name varchar
email varchar [not null, unique]
email_verified bool [not null, default: false]
mobile varchar [not null, unique]
mobile_verified bool [not null, default: false]
google_id varchar [unique]
role user_role
last_logout timestamp
created_at timestamp
updated_at timestamp
}
Table hashed_password {
id uuid
user_id uuid [ref: - users.id]
hashed_password varchar
}
Enum user_role {
CUSTOMER
SUPER_ADMIN
}
Table merchant {
id uuid [primary key]
restaurant_name varchar
address uuid [not null, ref: - address.id]
owner uuid [not null, ref: > users.id]
type merchant_type [not null, default: "DINE_IN"]
is_online bool [not null, default: false]
created_at timestamp
updated_at timestamp
}
Table merchant_managers {
id uuid [primary key]
user_id uuid [not null, ref: - users.id]
merchant_id uuid [not null, ref: > merchant.id]
role merchant_role
}
Enum merchant_role {
MERCHANT_ADMIN
MERCHANT_OPERATOR
MERCHANT_OWNER
}
Table timing {
id uuid [primary key]
merchant_id uuid [not null, ref: > merchant.id]
day_of_week day_of_week [not null]
open_time time
close_time time
is_closed bool [not null, default: false]
created_at timestamp
updated_at timestamp
indexes {
(merchant_id, day_of_week) [unique]
}
}
Enum day_of_week {
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
SUNDAY
}
Table address {
id uuid [primary key]
address_line1 varchar [not null]
address_line2 varchar
city varchar
district varchar
state varchar
pincode varchar(6)
created_at timestamp
updated_at timestamp
}
Table menu_category {
id uuid [primary key]
name varchar [not null]
merchant_id uuid [not null, ref : > merchant.id]
created_at timestamp
updated_at timestamp
}
Table menu_item {
id uuid [primary key]
merchant_id uuid [not null, ref: > merchant.id]
name varchar [not null]
description varchar
category uuid [not null, ref: > menu_category.id]
tag item_tag [not null]
price float [not null]
image_url varchar
created_at timestamp
updated_at timestamp
}
Enum merchant_type {
DINE_IN
TAKE_AWAY
}
Enum item_tag {
VEG
NONVEG
JAIN
}
Table merchant_table {
id uuid [primary key]
merchant_id uuid [not null, ref: > merchant.id]
table_number int [not null]
created_at timestamp
updated_at timestamp
indexes {
(merchant_id, table_number) [unique]
}
}
Table qr_code {
id uuid [primary key]
table_id uuid [ref: - merchant_table.id]
merchant_id uuid [not null, ref: > merchant.id]
created_at timestamp
updated_at timestamp
}
Table order {
id uuid [primary key]
token integer
merchant_id uuid [not null, ref: > merchant.id]
table_id uuid [ref: > merchant_table.id]
status order_status [not null, default: 'ACCEPTED']
total_amount float
created_at timestamp
updated_at timestamp
}
Table order_item {
id uuid [primary key]
item_id uuid [not null, ref: > menu_item.id]
order_id uuid [not null, ref: > order.id]
instruction varchar
quantity int
amount float
status order_item_status [not null, default: 'PREPARING']
created_at timestamp
}
Enum order_status {
ACCEPTED
PREPARING
COMPLETED
}
Enum order_item_status {
PREPARING
SERVED
}