aboutsummaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-16 14:31:32 +0000
committerAkshay <[email protected]>2020-12-16 14:31:32 +0000
commitaa5a6d212f6237ab696cb0f5b00d3d5e762d5fec (patch)
tree54df1d4f5026ba9742708f1fb6c60916f7008b08 /migrations
parent5cfdb0eb26e4c3c2b087378c8b882c0eff0409af (diff)
rework tables
Diffstat (limited to 'migrations')
-rw-r--r--migrations/2020-12-13-140215_all_tables/down.sql11
-rw-r--r--migrations/2020-12-13-140215_all_tables/up.sql47
2 files changed, 58 insertions, 0 deletions
diff --git a/migrations/2020-12-13-140215_all_tables/down.sql b/migrations/2020-12-13-140215_all_tables/down.sql
new file mode 100644
index 0000000..9c554a2
--- /dev/null
+++ b/migrations/2020-12-13-140215_all_tables/down.sql
@@ -0,0 +1,11 @@
1-- This file should undo anything in `up.sql`
2
3drop table customer;
4
5drop table product;
6
7drop table cart_items;
8
9drop table rating;
10
11drop table transaction;
diff --git a/migrations/2020-12-13-140215_all_tables/up.sql b/migrations/2020-12-13-140215_all_tables/up.sql
new file mode 100644
index 0000000..527b926
--- /dev/null
+++ b/migrations/2020-12-13-140215_all_tables/up.sql
@@ -0,0 +1,47 @@
1-- Your SQL goes here
2
3create table customer (
4 id integer primary key auto_increment,
5 username varchar(255) not null unique,
6 password varchar(255) not null,
7 phone_number varchar(10) not null,
8 email_id varchar(255) not null,
9 address text(500)
10);
11
12create table product (
13 id integer primary key auto_increment,
14 name varchar(255) not null,
15 kind varchar(255),
16 price float not null,
17 description varchar(255)
18);
19
20create table cart_items (
21 cart_id integer,
22 product_id integer,
23 constraint cart_items_pk primary key (cart_id, product_id),
24 foreign key (cart_id) references customer(id),
25 foreign key (product_id) references product(id)
26);
27
28create table rating (
29 id integer primary key auto_increment,
30 comment_text text(500),
31 comment_date date default curdate(),
32 product_id integer,
33 customer_id integer,
34
35 stars integer check (stars >= 0 AND stars <= 5),
36 foreign key (customer_id) references customer(id),
37 foreign key (product_id) references product(id)
38);
39
40create table transaction (
41 id integer primary key auto_increment,
42 payment_type varchar(255) not null,
43 amount float not null,
44 customer_id integer,
45
46 foreign key (customer_id) references customer(id)
47);