diff --git a/misc/update_1.1_to_1.2.sql b/misc/update_1.1_to_1.2.sql index 84d6516..198b144 100644 --- a/misc/update_1.1_to_1.2.sql +++ b/misc/update_1.1_to_1.2.sql @@ -49,3 +49,33 @@ ADD CONSTRAINT `FK_USER_PART` FOREIGN KEY (`participant_id`) REFERENCES `bremen_calling_devel`.`participant` (`id`); +-- History table for change tracking + +CREATE TABLE `bremen_calling_devel`.`history` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `participant_id` INT UNSIGNED NOT NULL, + `ship_id` INT UNSIGNED NOT NULL, + `timestamp` DATETIME NOT NULL COMMENT 'Time of saving', + `eta` DATETIME NOT NULL COMMENT 'Current ETA / ETD value (depends if shipcall or times were saved)', + `type` INT NOT NULL COMMENT 'shipcall or times', + `operation` INT NOT NULL COMMENT 'insert, update or delete', + PRIMARY KEY (`id`)) +COMMENT = 'This table stores a history of changes made to shipcalls so that everyone can see who changed what and when'; + +-- and foreign keys + +ALTER TABLE `bremen_calling_devel`.`history` +ADD INDEX `FK_HISTORY_PARTICIPANT_idx` (`participant_id` ASC) VISIBLE, +ADD INDEX `FK_HISTORY_SHIP_idx` (`ship_id` ASC) VISIBLE; +; +ALTER TABLE `bremen_calling_devel`.`history` +ADD CONSTRAINT `FK_HISTORY_PARTICIPANT` + FOREIGN KEY (`participant_id`) + REFERENCES `bremen_calling_devel`.`participant` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, +ADD CONSTRAINT `FK_HISTORY_SHIP` + FOREIGN KEY (`ship_id`) + REFERENCES `bremen_calling_devel`.`ship` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION;