From 6bfb0d3e23bb5a362da897d925a39dde9706ed8c Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 19 Nov 2024 12:11:57 +0100 Subject: [PATCH] fixed database upgrade script (1.5 -> 1.6) --- misc/update_1.5_to_1.6.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/misc/update_1.5_to_1.6.sql b/misc/update_1.5_to_1.6.sql index 842df4b..b17ba5a 100644 --- a/misc/update_1.5_to_1.6.sql +++ b/misc/update_1.5_to_1.6.sql @@ -12,31 +12,31 @@ CREATE TABLE `port` ( INSERT INTO port (id, name, locode) VALUES (1, 'Bremen', 'DEBRE'); -- Adding new ref column to berth -ALTER TABLE `bremen_calling_devel`.`berth` +ALTER TABLE `berth` ADD COLUMN `port_id` INT UNSIGNED DEFAULT NULL AFTER `authority_id`; -ALTER TABLE `bremen_calling_devel`.`berth` ALTER INDEX `FK_AUTHORITY_PART_idx` INVISIBLE; +ALTER TABLE `berth` ALTER INDEX `FK_AUTHORITY_PART_idx` INVISIBLE; -- adding a foreign key berth.port_id -> port.id -ALTER TABLE `bremen_calling_devel`.`berth` +ALTER TABLE `berth` ADD INDEX `FK_PORT_PART_idx` (`port_id` ASC) VISIBLE; -ALTER TABLE `bremen_calling_devel`.`berth` +ALTER TABLE `berth` ADD CONSTRAINT `FK_PORT` FOREIGN KEY (`port_id`) - REFERENCES `bremen_calling_devel`.`port` (`id`) + REFERENCES `port` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; -- adding new ref column to shipcall incl. foreign key -ALTER TABLE `bremen_calling_devel`.`shipcall` +ALTER TABLE `shipcall` ADD COLUMN `port_id` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Selected port for this shipcall' AFTER `evaluation_notifications_sent`, CHANGE COLUMN `time_ref_point` `time_ref_point` INT NULL DEFAULT '0' COMMENT 'Index of a location which is the reference point for all time value entries, e.g. berth or Geeste' AFTER `port_id`, ADD INDEX `FK_SHIPCALL_PORT_idx` (`port_id` ASC) VISIBLE; ; -ALTER TABLE `bremen_calling_devel`.`shipcall` +ALTER TABLE `shipcall` ADD CONSTRAINT `FK_SHIPCALL_PORT` FOREIGN KEY (`port_id`) - REFERENCES `bremen_calling_devel`.`port` (`id`) + REFERENCES `port` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; @@ -54,4 +54,4 @@ CREATE TABLE `participant_port_map` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Mapping table that assigns participants to a port'; -- all existing berths shall default to "bremen" -UPDATE berth SET port_id = 1; \ No newline at end of file +UPDATE berth SET port_id = 1 where port_id is null; \ No newline at end of file