salix/db/changes/10081-agency/00-zone.sql

57 lines
2.2 KiB
MySQL
Raw Normal View History

2019-10-04 12:27:55 +00:00
USE `vn`;
2019-09-26 08:08:37 +00:00
2019-10-04 12:27:55 +00:00
CREATE TABLE `vn`.`zoneWarehouse` (
2019-09-26 08:08:37 +00:00
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`zoneFk` int(11) NOT NULL,
`warehouseFk` smallint(6) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `zoneFk` (`zoneFk`,`warehouseFk`),
KEY `warehouseFk` (`warehouseFk`),
2019-11-06 12:44:58 +00:00
CONSTRAINT `zoneWarehouse_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE/*,
CONSTRAINT `zoneWarehouse_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE*/
2019-09-26 08:08:37 +00:00
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
2019-10-04 12:27:55 +00:00
CREATE TABLE `vn`.`zoneEvent` (
2019-09-26 08:08:37 +00:00
`id` int(11) NOT NULL AUTO_INCREMENT,
`zoneFk` int(11) NOT NULL,
`from` date DEFAULT NULL,
`to` date DEFAULT NULL,
`weekDays` set('mon','tue','wed','thu','fri','sat','sun') NOT NULL,
`hour` datetime DEFAULT NULL,
`travelingDays` int(11) DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL,
`bonus` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `zoneFk` (`zoneFk`),
CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
2019-11-18 15:31:37 +00:00
ALTER TABLE `vn`.`zoneEvent`
ADD COLUMN `type` ENUM('day', 'indefinitely', 'range') NOT NULL AFTER `zoneFk`,
ADD COLUMN `dated` DATE NULL DEFAULT NULL AFTER `type`,
CHANGE COLUMN `from` `started` DATE NULL DEFAULT NULL ,
CHANGE COLUMN `to` `ended` DATE NULL DEFAULT NULL ;
2019-10-04 12:27:55 +00:00
CREATE TABLE `vn`.`zoneExclusion` (
2019-09-26 08:08:37 +00:00
`id` int(11) NOT NULL AUTO_INCREMENT,
`zoneFk` int(11) NOT NULL,
`day` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `zoneFk_2` (`zoneFk`,`day`),
KEY `zoneFk` (`zoneFk`),
CONSTRAINT `zoneExclusion_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
2019-11-06 12:44:58 +00:00
ALTER TABLE `vn`.`zone`
2019-11-14 09:36:21 +00:00
DROP FOREIGN KEY `fk_zone_1`;
ALTER TABLE `vn`.`zone`
CHANGE COLUMN `warehouseFk` `warehouseFk` SMALLINT(6) UNSIGNED NULL DEFAULT NULL ;
2019-11-06 12:44:58 +00:00
ALTER TABLE `vn`.`zone`
2019-11-14 09:36:21 +00:00
ADD CONSTRAINT `fk_zone_1`
FOREIGN KEY (`warehouseFk`)
REFERENCES `vn`.`warehouse` (`id`)
ON DELETE NO ACTION
ON UPDATE CASCADE;
2019-11-18 15:31:37 +00:00
ALTER TABLE `vn`.`zoneExclusion`
CHANGE COLUMN `day` `dated` DATE NOT NULL ;