This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
78 lines (78 loc) · 12.1 KB
/
init.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
create table tb_category (created_at TIMESTAMP WITHOUT TIME ZONE, deleted_at TIMESTAMP WITHOUT TIME ZONE, id bigserial not null, updated_at TIMESTAMP WITHOUT TIME ZONE, name varchar(255) not null unique, primary key (id));
create table tb_customer (created_at TIMESTAMP WITHOUT TIME ZONE, deleted_at TIMESTAMP WITHOUT TIME ZONE, id bigserial not null, updated_at TIMESTAMP WITHOUT TIME ZONE, cpf varchar(255) not null unique, email varchar(255) not null, name varchar(255) not null, primary key (id));
create table tb_order (created_at TIMESTAMP WITHOUT TIME ZONE, customer_id bigint, deleted_at TIMESTAMP WITHOUT TIME ZONE, id bigserial not null, updated_at TIMESTAMP WITHOUT TIME ZONE, status varchar(255) check (status in ('DRAFT','SUBMITTED','PREPARING','READY','DELIVERED','CANCELED')), primary key (id));
create table tb_order_item (total_price float(53) not null check (total_price>=0), id bigserial not null, order_id bigint not null, product_id bigint not null, quantity bigint not null check (quantity>=1), primary key (id));
create table tb_payment (amount float(53) not null check (amount>=0), created_at TIMESTAMP WITHOUT TIME ZONE, deleted_at TIMESTAMP WITHOUT TIME ZONE, id bigserial not null, order_id bigint not null unique, updated_at TIMESTAMP WITHOUT TIME ZONE, status varchar(255) check (status in ('NOT_SUBMITTED','PROCESSING','REJECTED','COLLECTED')), primary key (id));
create table tb_product (price float(53) not null, category_id bigint not null, created_at TIMESTAMP WITHOUT TIME ZONE, deleted_at TIMESTAMP WITHOUT TIME ZONE, id bigserial not null, updated_at TIMESTAMP WITHOUT TIME ZONE, description TEXT not null, img_url varchar(255) not null, name varchar(255) not null, primary key (id));
alter table if exists tb_order add constraint FKqcp43jdylvf2riad5s1x1i2dn foreign key (customer_id) references tb_customer;
alter table if exists tb_order_item add constraint FKgeobgl2xu916he8vhljktwxnx foreign key (order_id) references tb_order;
alter table if exists tb_order_item add constraint FK4h5xid5qehset7qwe5l9c997x foreign key (product_id) references tb_product;
alter table if exists tb_payment add constraint FKokaf4il2cwit4h780c25dv04r foreign key (order_id) references tb_order;
alter table if exists tb_product add constraint FK8i0sq9mfbpsrabrm2pum9fspo foreign key (category_id) references tb_category;
INSERT INTO tb_category (name, created_at) VALUES ('Snacks', NOW());
INSERT INTO tb_category (name, created_at) VALUES ('Drinks', NOW());
INSERT INTO tb_category (name, created_at) VALUES ('Desserts', NOW());
INSERT INTO tb_category (name, created_at) VALUES ('Sides', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('X-Burguer', 14.9, 1, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('X-Bacon', 12.9, 1, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('X-Chicken', 14.9, 1, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('X-Fish', 15.9, 1, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('CheeseBurguer', 12.9, 1, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Coca-Cola', 9.9, 2, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Lemonade', 10.9, 2, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Orange Juice', 11.9, 2, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Water', 7.9, 2, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Ice Tea', 10.9, 2, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Vanilla Sundae', 8.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Strawberry Sundae', 8.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Chocolate Sundae', 8.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Vanilla Shake', 13.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Strawberry Shake', 13.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Chocolate Shake', 13.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Vanilla Cone', 5.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Chocolate Cone', 5.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Mixed Cone', 5.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Banana Pie', 7.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Apple Cone', 7.9, 3, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('French Fries', 8.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Mustard', 1.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Ketchup', 1.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Mayonnaise', 1.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Barbeque Sauce', 1.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_product (name, price, category_id, description, img_url, created_at) VALUES ('Chicken Nuggets', 10.9, 4, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate rutrum ullamcorper.', 'https://', NOW());
INSERT INTO tb_customer (name, cpf, email, created_at) VALUES ('John', '20195054016', '[email protected]', NOW());
INSERT INTO tb_customer (name, cpf, email, created_at) VALUES ('Mary', '81018255095', '[email protected]', NOW());
INSERT INTO tb_customer (name, cpf, email, created_at) VALUES ('Jack', '50260304085', '[email protected]', NOW());
INSERT INTO tb_customer (name, cpf, email, created_at) VALUES ('Lysa', '38877348070', '[email protected]', NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('DRAFT', 1, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('SUBMITTED', 2, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('DRAFT', 3, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('PREPARING', 4, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('READY', 1, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('SUBMITTED', 3, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('DELIVERED', 2, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('PREPARING', 2, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('READY', 4, NOW());
INSERT INTO tb_order (status, customer_id, created_at) VALUES ('DELIVERED', 4, NOW());
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (2, 1, 1, 14.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (4, 3, 2, 29.8);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (5, 17, 2, 11.8);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (5, 6, 1, 9.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (6, 17, 3, 17.7);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (7, 5, 1, 12.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (7, 2, 1, 12.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (7, 8, 2, 23.8);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (8, 20, 1, 7.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (9, 22, 2, 17.8);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (10, 12, 1, 8.9);
INSERT INTO tb_order_item (order_id, product_id, quantity, total_price) VALUES (10, 15, 1, 13.9);
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (1, 0.0, 'NOT_SUBMITTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (2, 14.9, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (3, 0.0, 'NOT_SUBMITTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (4, 29.8, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (5, 21.7, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (6, 17.7, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (7, 49.6, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (8, 7.9, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (9, 17.8, 'COLLECTED', NOW());
INSERT INTO tb_payment (order_id, amount, status, created_at) VALUES (10, 22.8, 'COLLECTED', NOW());