From 3ae282102c4bde1b3f0631b471cb3512d429eee8 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 20 Dec 2023 10:45:43 +0100 Subject: [PATCH] All database changes in an update script. Devel database is already updated. --- misc/update_1.1_to_1.2.sql | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 misc/update_1.1_to_1.2.sql diff --git a/misc/update_1.1_to_1.2.sql b/misc/update_1.1_to_1.2.sql new file mode 100644 index 0000000..84d6516 --- /dev/null +++ b/misc/update_1.1_to_1.2.sql @@ -0,0 +1,51 @@ +-- add notification handling columns to shipcall +-- evaluation_time: Time when the "traffic light" was last changed +-- evaluation_notifications_sent: Flag to indicate if notifications were sent for the current evaluation + +ALTER TABLE `bremen_calling_devel`.`shipcall` +ADD COLUMN `evaluation_time` DATETIME NULL DEFAULT NULL AFTER `evaluation_message`, +ADD COLUMN `evaluation_notifications_sent` BIT NULL AFTER `evaluation_time`; + + + +-- prepare notification table for historic notification data +-- removed reference to participant and times and dropped unnecessary columns +-- added reference to shipcall + +ALTER TABLE `bremen_calling_devel`.`notification` +DROP FOREIGN KEY `FK_NOT_TIMES`, +DROP FOREIGN KEY `FK_NOT_PART`; +ALTER TABLE `bremen_calling_devel`.`notification` +DROP COLUMN `deleted`, +DROP COLUMN `acknowledged`, +DROP COLUMN `participant_id`, +DROP COLUMN `times_id`, +ADD COLUMN `shipcall_id` INT UNSIGNED NULL AFTER `id`, +ADD INDEX `FK_NOTIFICATION_SHIPCALL_idx` (`shipcall_id` ASC) VISIBLE, +DROP INDEX `FK_NOT_PART` , +DROP INDEX `FK_NOT_TIMES` ; +; +ALTER TABLE `bremen_calling_devel`.`notification` +ADD CONSTRAINT `FK_NOTIFICATION_SHIPCALL` + FOREIGN KEY (`shipcall_id`) + REFERENCES `bremen_calling_devel`.`shipcall` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + + +-- added notification flags +-- participant reference is now mandatory + +ALTER TABLE `bremen_calling_devel`.`user` +DROP FOREIGN KEY `FK_USER_PART`; +ALTER TABLE `bremen_calling_devel`.`user` +ADD COLUMN `notify_email` BIT NULL DEFAULT NULL AFTER `api_key`, +ADD COLUMN `notify_whatsapp` BIT NULL DEFAULT NULL AFTER `notify_email`, +ADD COLUMN `notify_signal` BIT NULL DEFAULT NULL AFTER `notify_whatsapp`, +ADD COLUMN `notifiy_popup` BIT NULL DEFAULT NULL AFTER `notify_signal`, +CHANGE COLUMN `participant_id` `participant_id` INT UNSIGNED NOT NULL ; +ALTER TABLE `bremen_calling_devel`.`user` +ADD CONSTRAINT `FK_USER_PART` + FOREIGN KEY (`participant_id`) + REFERENCES `bremen_calling_devel`.`participant` (`id`); +