salix/db/changes/234801/00-sectorBackUpLabelerFk.sql

31 lines
1.7 KiB
MySQL
Raw Normal View History

ALTER TABLE `util`.`notification` ADD delay INT NULL
COMMENT 'Minimum Milliseconds Interval to Prevent Spam from Same-Type Notifications';
ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` tinyint(3) unsigned DEFAULT NULL NULL;
ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`;
ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY `nnotificationQueue_ibfk_1`;
ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`;
ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL;
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
DELETE FROM `util`.`notification`
WHERE `name` = 'not-main-printer-configured';
INSERT INTO `util`.`notification`
SET `name` = 'backup-printer-selected',
`description` = 'The worker has selected the backup printer for their sector',
`delay` = 600000;
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
SELECT `n`.`id`, `r`.`id`
FROM `util`.`notification` `n`
JOIN `account`.`role` `r`
WHERE `n`.`name` = 'backup-printer-selected'
AND `r`.`name` = 'system'
LIMIT 1;