salix/db/changes/10100-AllSaints/00-zone.sql

39 lines
1.5 KiB
SQL

USE `vn`;
CREATE TABLE `vn`.`zoneWarehouse` (
`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`),
CONSTRAINT `zoneWarehouse_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `zoneWarehouse_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
CREATE TABLE `vn`.`zoneEvent` (
`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;
CREATE TABLE `vn`.`zoneExclusion` (
`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;