-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sql
24 lines (24 loc) · 943 Bytes
/
script.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
DROP TABLE IF EXISTS consumption;
DROP TABLE IF EXISTS coupon;
CREATE TABLE coupon
(
id BIGINT NOT NULL AUTO_INCREMENT,
code VARCHAR(255) NOT NULL,
remaining_usages INT NOT NULL,
expiry_date DATE NOT NULL,
value DECIMAL(38, 2) NOT NULL,
active BIT NOT NULL,
type enum ('FIXED', 'PERCENTAGE') null,
PRIMARY KEY (id)
);
create table consumption
(
id BIGINT NOT NULL AUTO_INCREMENT,
actual_discount DECIMAL(38, 2) not null,
consumption_date TIMESTAMP not null,
coupon_id BIGINT not null,
customer_email VARCHAR(255) not null,
order_id BIGINT not null,
PRIMARY KEY (id),
FOREIGN KEY (coupon_id) REFERENCES coupon (id)
);