Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SystemDev_HRProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tran15.Anh@live.uwe.ac.uk
SystemDev_HRProject
Commits
85aabdcc
Commit
85aabdcc
authored
2 months ago
by
duyanhehe
Browse files
Options
Downloads
Patches
Plain Diff
fix docker using schema
parent
69602d92
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/schema.sql
+0
-121
0 additions, 121 deletions
app/schema.sql
docker-compose.yml
+1
-1
1 addition, 1 deletion
docker-compose.yml
with
1 addition
and
122 deletions
app/schema.sql
deleted
100644 → 0
+
0
−
121
View file @
69602d92
DROP
TABLE
IF
EXISTS
reports
,
discounts
,
inventory
,
reservations
,
payments
,
order_items
,
orders
,
menu
,
users
,
restaurants
;
CREATE
TABLE
restaurants
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
name
VARCHAR
(
255
)
NOT
NULL
,
city
VARCHAR
(
100
)
NOT
NULL
,
address
VARCHAR
(
255
)
NOT
NULL
,
phone
VARCHAR
(
20
),
email
VARCHAR
(
100
),
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
);
CREATE
TABLE
users
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
full_name
VARCHAR
(
255
)
NOT
NULL
,
email
VARCHAR
(
255
)
UNIQUE
NOT
NULL
,
phone
VARCHAR
(
20
),
password_hash
VARCHAR
(
255
)
NOT
NULL
,
role
ENUM
(
'admin'
,
'manager'
,
'staff'
,
'customer'
)
NOT
NULL
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
SET
NULL
);
CREATE
TABLE
menu
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
name
VARCHAR
(
255
)
NOT
NULL
,
description
TEXT
,
price
DECIMAL
(
10
,
2
)
NOT
NULL
,
category
VARCHAR
(
100
),
available
BOOLEAN
DEFAULT
TRUE
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
);
CREATE
TABLE
discounts
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
code
VARCHAR
(
50
)
UNIQUE
NOT
NULL
,
description
TEXT
,
discount_percent
DECIMAL
(
5
,
2
),
valid_from
DATE
NOT
NULL
,
valid_to
DATE
NOT
NULL
,
status
ENUM
(
'active'
,
'expired'
)
DEFAULT
'active'
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
);
CREATE
TABLE
orders
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
user_id
INT
NULL
,
table_number
INT
,
total_amount
DECIMAL
(
10
,
2
),
discount_id
INT
,
discount_amount
DECIMAL
(
10
,
2
),
service_fee
DECIMAL
(
10
,
2
),
vat
DECIMAL
(
10
,
2
),
grand_total
DECIMAL
(
10
,
2
),
order_status
ENUM
(
'pending'
,
'preparing'
,
'ready'
,
'completed'
,
'cancelled'
)
DEFAULT
'pending'
,
payment_status
ENUM
(
'pending'
,
'paid'
,
'failed'
)
DEFAULT
'pending'
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
user_id
)
REFERENCES
users
(
id
)
ON
DELETE
SET
NULL
,
FOREIGN
KEY
(
discount_id
)
REFERENCES
discounts
(
id
)
ON
DELETE
SET
NULL
);
CREATE
TABLE
order_items
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
order_id
INT
,
menu_id
INT
,
quantity
INT
NOT
NULL
,
subtotal
DECIMAL
(
10
,
2
)
NOT
NULL
,
FOREIGN
KEY
(
order_id
)
REFERENCES
orders
(
id
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
menu_id
)
REFERENCES
menu
(
id
)
ON
DELETE
CASCADE
);
CREATE
TABLE
payments
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
order_id
INT
,
user_id
INT
,
amount
DECIMAL
(
10
,
2
)
NOT
NULL
,
payment_method
ENUM
(
'cash'
,
'credit_card'
,
'paypal'
)
NOT
NULL
,
transaction_id
VARCHAR
(
100
)
UNIQUE
,
status
ENUM
(
'success'
,
'failed'
,
'pending'
)
DEFAULT
'pending'
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
order_id
)
REFERENCES
orders
(
id
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
user_id
)
REFERENCES
users
(
id
)
ON
DELETE
SET
NULL
);
CREATE
TABLE
reservations
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
user_id
INT
,
table_number
INT
,
reservation_time
DATETIME
NOT
NULL
,
status
ENUM
(
'pending'
,
'confirmed'
,
'cancelled'
)
DEFAULT
'pending'
,
created_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
user_id
)
REFERENCES
users
(
id
)
ON
DELETE
SET
NULL
);
CREATE
TABLE
inventory
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
item_name
VARCHAR
(
255
)
NOT
NULL
,
quantity
INT
NOT
NULL
,
unit
VARCHAR
(
50
),
last_updated
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
);
CREATE
TABLE
reports
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
restaurant_id
INT
,
report_type
ENUM
(
'sales'
,
'inventory'
,
'customer_feedback'
)
NOT
NULL
,
generated_at
TIMESTAMP
DEFAULT
CURRENT_TIMESTAMP
,
data
JSON
NOT
NULL
,
FOREIGN
KEY
(
restaurant_id
)
REFERENCES
restaurants
(
id
)
ON
DELETE
CASCADE
);
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
1
−
1
View file @
85aabdcc
...
@@ -34,7 +34,7 @@ services:
...
@@ -34,7 +34,7 @@ services:
-
"
3306:3306"
-
"
3306:3306"
volumes
:
volumes
:
-
mysql_data:/var/lib/mysql
-
mysql_data:/var/lib/mysql
-
./app/schema.sql:/docker-entrypoint-initdb.d/schema.sql
networks
:
networks
:
-
app-network
-
app-network
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment