2022-10-11 11:20:25 +00:00
|
|
|
USE util;
|
|
|
|
|
|
|
|
CREATE TABLE notification(
|
|
|
|
id INT PRIMARY KEY,
|
|
|
|
`name` VARCHAR(255) UNIQUE,
|
|
|
|
`description` VARCHAR(255)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE notificationAcl(
|
2022-10-14 11:22:53 +00:00
|
|
|
notificationFk INT,
|
|
|
|
roleFk INT(10) unsigned,
|
2022-10-11 11:20:25 +00:00
|
|
|
PRIMARY KEY(notificationFk, roleFk)
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`)
|
|
|
|
ON DELETE RESTRICT
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
CREATE TABLE notificationSubscription(
|
2022-10-14 11:22:53 +00:00
|
|
|
notificationFk INT,
|
|
|
|
userFk INT(10) unsigned,
|
2022-10-11 11:20:25 +00:00
|
|
|
PRIMARY KEY(notificationFk, userFk)
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
CREATE TABLE notificationQueue(
|
|
|
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
2022-10-14 11:22:53 +00:00
|
|
|
notificationFk VARCHAR(255),
|
|
|
|
params JSON,
|
|
|
|
authorFk INT(10) unsigned NULL,
|
2022-10-11 11:20:25 +00:00
|
|
|
`status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending',
|
|
|
|
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
INDEX(notificationFk),
|
|
|
|
INDEX(authorFk),
|
|
|
|
INDEX(status)
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `nnotificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`name`)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user`(`id`)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
CREATE TABLE notificationConfig(
|
|
|
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
|
|
cleanDays MEDIUMINT
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO notificationConfig
|
|
|
|
SET cleanDays = 90;
|