Skip to content

Commit d2fdb4f

Browse files
committed
updated foriegn key
1 parent 2609ecf commit d2fdb4f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

depot/db/create.sql

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ drop table if exists orders;
44
drop table if exists products;
55

66
create table products (
7-
id int not null auto_increment,
8-
title varchar(100) not null,
7+
id int(11) not null auto_increment,
8+
title varchar(100) not null default '',
99
description text not null,
10-
image_url varchar(200) not null,
11-
price decimal(10,2) not null,
12-
date_available datetime not null,
10+
image_url varchar(200) not null default '',
11+
price decimal(10,2) not null default '0.00',
12+
date_available datetime not null default '0000-00-00 00:00:00',
1313
primary key (id)
1414
);
1515

1616
/*START:orders*/
1717
create table orders (
18-
id int not null auto_increment,
18+
id int(11) not null auto_increment,
1919
name varchar(100) not null,
2020
email varchar(255) not null,
2121
address text not null,
2222
pay_type char(10) not null,
23-
shipped_at datetime null,
23+
shipped_at datetime null,
2424
primary key (id)
2525
);
2626
/*END:orders*/
2727

2828
create table line_items (
29-
id int not null auto_increment,
30-
product_id int not null,
31-
order_id int not null,
32-
quantity int not null default 0,
33-
unit_price decimal(10,2) not null,
34-
constraint fk_items_product foreign key (product_id) references products(id),
35-
constraint fk_items_order foreign key (order_id) references orders(id),
36-
primary key (id)
29+
id int(11) not null auto_increment,
30+
product_id int(11) not null,
31+
order_id int(11) not null,
32+
quantity int(11) not null default 0,
33+
unit_price decimal(10,2) not null,
34+
primary key (id),
35+
KEY `fk_items_product` (`product_id`),
36+
KEY `fk_items_order` (`order_id`)
3737
);
3838

3939

0 commit comments

Comments
 (0)