-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.txt
37 lines (29 loc) · 998 Bytes
/
migrate.txt
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
2010-12-16
----------
ALTER TABLE wine_years
ADD UNIQUE KEY `wine_uni` (`winecellar_id`,`wine_id`,`year`);
2011-01-06
----------
DROP TABLE IF EXISTS `shoppinglist`;
CREATE TABLE IF NOT EXISTS `shoppinglist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`producer` varchar(50) DEFAULT NULL,
`year` int(11) DEFAULT NULL,
`quantity` int(11) NOT NULL,
`store` varchar(50) DEFAULT NULL,
`bottle_size` smallint(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `shoppinglist`
ADD CONSTRAINT `shoppinglist_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
2011-01-18
----------
ALTER TABLE `shoppinglist`
CHANGE `name` `name` VARCHAR(50) NULL,
ADD `wine_id` INT NULL AFTER `user_id`,
ADD INDEX (`wine_id`),
ADD FOREIGN KEY (`wine_id`) REFERENCES `wines` (`id`)
ON DELETE RESTRICT ON UPDATE CASCADE ;