492 lines
22 KiB
SQL
492 lines
22 KiB
SQL
-- MySQL dump 10.13 Distrib 8.0.43, for Win64 (x86_64)
|
|
--
|
|
-- Host: localhost Database: bremen_calling_test
|
|
-- ------------------------------------------------------
|
|
-- Server version 8.0.42-0ubuntu0.24.10.1
|
|
|
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
/*!50503 SET NAMES utf8 */;
|
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
|
|
--
|
|
-- Table structure for table `berth`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `berth`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `berth` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(128) DEFAULT NULL COMMENT 'Descriptive name',
|
|
`lock` bit(1) DEFAULT NULL COMMENT 'The lock must be used',
|
|
`owner_id` int unsigned DEFAULT NULL,
|
|
`authority_id` int unsigned DEFAULT NULL,
|
|
`port_id` int unsigned DEFAULT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
`deleted` bit(1) DEFAULT b'0',
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_OWNER_PART_idx` (`owner_id`),
|
|
KEY `FK_AUTHORITY_PART_idx` (`authority_id`) /*!80000 INVISIBLE */,
|
|
KEY `FK_PORT_PART_idx` (`port_id`),
|
|
CONSTRAINT `FK_AUTHORITY_PART` FOREIGN KEY (`authority_id`) REFERENCES `participant` (`id`),
|
|
CONSTRAINT `FK_OWNER_PART` FOREIGN KEY (`owner_id`) REFERENCES `participant` (`id`),
|
|
CONSTRAINT `FK_PORT` FOREIGN KEY (`port_id`) REFERENCES `port` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
|
) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Berth of ship for a ship call';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `history`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `history`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `history` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`participant_id` int unsigned NOT NULL,
|
|
`user_id` int unsigned DEFAULT NULL,
|
|
`shipcall_id` int unsigned NOT NULL,
|
|
`timestamp` datetime NOT NULL COMMENT 'Time of saving',
|
|
`eta` datetime DEFAULT 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`),
|
|
KEY `FK_HISTORY_PARTICIPANT_idx` (`participant_id`),
|
|
KEY `FK_HISTORY_SHIPCALL_idx` (`shipcall_id`),
|
|
KEY `FK_HISTORY_USER` (`user_id`),
|
|
CONSTRAINT `FK_HISTORY_PARTICIPANT` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`),
|
|
CONSTRAINT `FK_HISTORY_SHIPCALL` FOREIGN KEY (`shipcall_id`) REFERENCES `shipcall` (`id`),
|
|
CONSTRAINT `FK_HISTORY_USER` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=23537 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='This table stores a history of changes made to shipcalls so that everyone can see who changed what and when';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `notification`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `notification`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `notification` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`shipcall_id` int unsigned DEFAULT NULL,
|
|
`participant_id` int unsigned DEFAULT NULL,
|
|
`level` tinyint DEFAULT NULL COMMENT 'severity of the notification',
|
|
`type` tinyint DEFAULT NULL COMMENT 'Email/UI/Other',
|
|
`message` varchar(512) DEFAULT NULL COMMENT 'individual message',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_NOTIFICATION_SHIPCALL_idx` (`shipcall_id`),
|
|
KEY `FK_NOTIFICATION_PARTICIPANT_idx` (`participant_id`),
|
|
CONSTRAINT `FK_NOTIFICATION_PARTICIPANT` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
|
CONSTRAINT `FK_NOTIFICATION_SHIPCALL` FOREIGN KEY (`shipcall_id`) REFERENCES `shipcall` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=10398 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='An entry corresponds to an alarm given by a violated rule during times update';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `participant`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `participant`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `participant` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(128) DEFAULT NULL,
|
|
`street` varchar(128) DEFAULT NULL,
|
|
`postal_code` varchar(5) DEFAULT NULL,
|
|
`city` varchar(64) DEFAULT NULL,
|
|
`type` int DEFAULT NULL,
|
|
`flags` int unsigned DEFAULT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
`deleted` bit(1) DEFAULT b'0',
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=160 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='An organization taking part';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `participant_port_map`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `participant_port_map`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `participant_port_map` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`participant_id` int unsigned NOT NULL COMMENT 'Ref to participant',
|
|
`port_id` int unsigned NOT NULL COMMENT 'Ref to port',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_PP_PARTICIPANT` (`participant_id`),
|
|
KEY `FK_PP_PORT` (`port_id`),
|
|
CONSTRAINT `FK_PP_PARTICIPANT` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`),
|
|
CONSTRAINT `FK_PP_PORT` FOREIGN KEY (`port_id`) REFERENCES `port` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Mapping table that assigns participants to a port';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `port`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `port`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `port` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(128) NOT NULL COMMENT 'Name of port',
|
|
`locode` char(5) DEFAULT NULL COMMENT 'UNECE locode',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
`deleted` bit(1) DEFAULT b'0',
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Port as reference for shipcalls and berths';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `role`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `role`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `role` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(50) NOT NULL DEFAULT '0' COMMENT 'unique role name',
|
|
`description` varchar(255) DEFAULT '0' COMMENT 'role description',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `name` (`name`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='logical group of securables for one or more user';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `role_securable_map`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `role_securable_map`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `role_securable_map` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`role_id` int unsigned NOT NULL,
|
|
`securable_id` int unsigned NOT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_ROLE_SECURABLE` (`role_id`),
|
|
KEY `FK_SECURABLE_ROLE` (`securable_id`),
|
|
CONSTRAINT `FK_ROLE_SECURABLE` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`),
|
|
CONSTRAINT `FK_SECURABLE_ROLE` FOREIGN KEY (`securable_id`) REFERENCES `securable` (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Assigns securables to roles';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `securable`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `securable`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `securable` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(50) NOT NULL DEFAULT '',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `name` (`name`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Actual permission on a single(!) feature or operation';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `ship`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `ship`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `ship` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(64) DEFAULT NULL,
|
|
`imo` int DEFAULT NULL,
|
|
`callsign` varchar(8) DEFAULT NULL,
|
|
`participant_id` int unsigned DEFAULT NULL,
|
|
`length` float DEFAULT NULL,
|
|
`width` float DEFAULT NULL,
|
|
`is_tug` bit(1) DEFAULT b'0',
|
|
`bollard_pull` int DEFAULT NULL,
|
|
`eni` int DEFAULT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
`deleted` bit(1) DEFAULT b'0',
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_SHIP_PARTICIPANT` (`participant_id`),
|
|
CONSTRAINT `FK_SHIP_PARTICIPANT` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=485 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `shipcall`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `shipcall`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `shipcall` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`ship_id` int unsigned DEFAULT NULL,
|
|
`type` tinyint DEFAULT NULL,
|
|
`eta` datetime DEFAULT NULL,
|
|
`voyage` varchar(16) DEFAULT NULL,
|
|
`etd` datetime DEFAULT NULL,
|
|
`arrival_berth_id` int unsigned DEFAULT NULL,
|
|
`departure_berth_id` int unsigned DEFAULT NULL,
|
|
`tug_required` bit(1) DEFAULT NULL,
|
|
`pilot_required` bit(1) DEFAULT NULL,
|
|
`flags` int unsigned DEFAULT '0',
|
|
`pier_side` bit(1) DEFAULT NULL,
|
|
`bunkering` bit(1) DEFAULT NULL,
|
|
`replenishing_terminal` bit(1) DEFAULT NULL,
|
|
`replenishing_lock` bit(1) DEFAULT NULL,
|
|
`draft` float DEFAULT NULL,
|
|
`tidal_window_from` datetime DEFAULT NULL,
|
|
`tidal_window_to` datetime DEFAULT NULL,
|
|
`rain_sensitive_cargo` bit(1) DEFAULT b'0',
|
|
`recommended_tugs` int DEFAULT '0',
|
|
`anchored` bit(1) DEFAULT NULL,
|
|
`moored_lock` bit(1) DEFAULT NULL,
|
|
`canceled` bit(1) DEFAULT NULL,
|
|
`evaluation` int unsigned DEFAULT NULL,
|
|
`evaluation_message` varchar(512) DEFAULT NULL,
|
|
`evaluation_time` datetime DEFAULT NULL,
|
|
`evaluation_notifications_sent` bit(1) DEFAULT NULL,
|
|
`port_id` int unsigned NOT NULL DEFAULT '1' COMMENT 'Selected port for this shipcall',
|
|
`time_ref_point` int DEFAULT '0' COMMENT 'Index of a location which is the reference point for all time value entries, e.g. berth or Geeste',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_SHIPCALL_SHIP` (`ship_id`),
|
|
KEY `FK_SHIPCALL_BERTH_ARRIVAL` (`arrival_berth_id`),
|
|
KEY `FK_SHIPCALL_BERTH_DEPARTURE` (`departure_berth_id`),
|
|
KEY `idx_shipcall_type` (`type`),
|
|
KEY `idx_shipcall_eta` (`eta`),
|
|
KEY `idx_shipcall_etd` (`etd`),
|
|
KEY `FK_SHIPCALL_PORT_idx` (`port_id`),
|
|
CONSTRAINT `FK_SHIPCALL_BERTH_ARRIVAL` FOREIGN KEY (`arrival_berth_id`) REFERENCES `berth` (`id`),
|
|
CONSTRAINT `FK_SHIPCALL_BERTH_DEPARTURE` FOREIGN KEY (`departure_berth_id`) REFERENCES `berth` (`id`),
|
|
CONSTRAINT `FK_SHIPCALL_PORT` FOREIGN KEY (`port_id`) REFERENCES `port` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
|
CONSTRAINT `FK_SHIPCALL_SHIP` FOREIGN KEY (`ship_id`) REFERENCES `ship` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=2789 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Incoming, outgoing or moving to another berth';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `shipcall_participant_map`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `shipcall_participant_map`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `shipcall_participant_map` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`shipcall_id` int unsigned DEFAULT NULL,
|
|
`participant_id` int unsigned DEFAULT NULL,
|
|
`type` int unsigned DEFAULT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_MAP_PARTICIPANT_SHIPCALL` (`shipcall_id`),
|
|
KEY `FK_MAP_SHIPCALL_PARTICIPANT` (`participant_id`),
|
|
CONSTRAINT `FK_MAP_PARTICIPANT_SHIPCALL` FOREIGN KEY (`shipcall_id`) REFERENCES `shipcall` (`id`) ON DELETE SET NULL,
|
|
CONSTRAINT `FK_MAP_SHIPCALL_PARTICIPANT` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=8933 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Associates a participant with a shipcall';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `shipcall_tug_map`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `shipcall_tug_map`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `shipcall_tug_map` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`shipcall_id` int unsigned NOT NULL COMMENT 'Ref to ship call',
|
|
`ship_id` int unsigned NOT NULL COMMENT 'Ref to ship (that is a tug)',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_SCT_SHIP` (`ship_id`),
|
|
KEY `FK_SCT_SHIPCALL` (`shipcall_id`),
|
|
CONSTRAINT `FK_SCT_SHIP` FOREIGN KEY (`ship_id`) REFERENCES `ship` (`id`),
|
|
CONSTRAINT `FK_SCT_SHIPCALL` FOREIGN KEY (`shipcall_id`) REFERENCES `shipcall` (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Mapping table that assigns tugs to a ship call';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `times`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `times`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `times` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`eta_berth` datetime DEFAULT NULL,
|
|
`eta_berth_fixed` bit(1) DEFAULT NULL,
|
|
`etd_berth` datetime DEFAULT NULL,
|
|
`etd_berth_fixed` bit(1) DEFAULT NULL,
|
|
`lock_time` datetime DEFAULT NULL,
|
|
`lock_time_fixed` bit(1) DEFAULT NULL,
|
|
`zone_entry` datetime DEFAULT NULL,
|
|
`zone_entry_fixed` bit(1) DEFAULT NULL,
|
|
`operations_start` datetime DEFAULT NULL,
|
|
`operations_end` datetime DEFAULT NULL,
|
|
`remarks` varchar(512) DEFAULT NULL,
|
|
`shipcall_id` int unsigned NOT NULL,
|
|
`participant_id` int unsigned NOT NULL,
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
`berth_id` int unsigned DEFAULT NULL,
|
|
`berth_info` varchar(512) DEFAULT NULL,
|
|
`pier_side` bit(1) DEFAULT NULL,
|
|
`participant_type` int unsigned DEFAULT NULL,
|
|
`ata` datetime DEFAULT NULL COMMENT 'Relevant only for mooring, this field can be used to record actual ATA',
|
|
`atd` datetime DEFAULT NULL COMMENT 'Relevant only for mooring, this field can be used to record actual ATD',
|
|
`eta_interval_end` datetime DEFAULT NULL COMMENT 'If this value is set the times are given as interval instead of a single point in time. The start time value depends on the participant type.',
|
|
`etd_interval_end` datetime DEFAULT NULL COMMENT 'If this value is set the times are given as interval instead of a single point in time. The start time value depends on the participant type.',
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_shipcall_participant` (`shipcall_id`,`participant_type`),
|
|
KEY `FK_TIME_SHIPCALL` (`shipcall_id`),
|
|
KEY `FK_TIME_PART` (`participant_id`) /*!80000 INVISIBLE */,
|
|
KEY `FK_TIME_BERTH` (`berth_id`) /*!80000 INVISIBLE */,
|
|
KEY `idx_times_eta_berth` (`eta_berth`),
|
|
KEY `idx_times_etd_berth` (`etd_berth`),
|
|
CONSTRAINT `FK_TIME_BERTH` FOREIGN KEY (`berth_id`) REFERENCES `berth` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
|
CONSTRAINT `FK_TIME_PART` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=7863 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='the planned time for the participants work';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `user`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `user`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `user` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`participant_id` int unsigned NOT NULL,
|
|
`first_name` varchar(45) DEFAULT NULL,
|
|
`last_name` varchar(45) DEFAULT NULL,
|
|
`user_name` varchar(45) DEFAULT NULL,
|
|
`user_email` varchar(128) DEFAULT NULL,
|
|
`user_phone` varchar(128) DEFAULT NULL,
|
|
`password_hash` varchar(128) DEFAULT NULL,
|
|
`api_key` varchar(256) DEFAULT NULL,
|
|
`notify_email` bit(1) DEFAULT NULL,
|
|
`notify_whatsapp` bit(1) DEFAULT NULL,
|
|
`notify_signal` bit(1) DEFAULT NULL,
|
|
`notify_popup` bit(1) DEFAULT NULL,
|
|
`notify_event` int DEFAULT NULL COMMENT 'Bitflag of selected notification event types that the user wants to be notified of',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_USER_PART` (`participant_id`),
|
|
CONSTRAINT `FK_USER_PART` FOREIGN KEY (`participant_id`) REFERENCES `participant` (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='member of a participant';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Table structure for table `user_role_map`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `user_role_map`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!50503 SET character_set_client = utf8mb4 */;
|
|
CREATE TABLE `user_role_map` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned NOT NULL DEFAULT '0',
|
|
`role_id` int unsigned NOT NULL DEFAULT '0',
|
|
`created` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `FK_USER_ROLE` (`user_id`),
|
|
KEY `FK_ROLE_USER` (`role_id`),
|
|
CONSTRAINT `FK_ROLE_USER` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`),
|
|
CONSTRAINT `FK_USER_ROLE` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Assigns a user to a role';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Dumping routines for database 'bremen_calling_test'
|
|
--
|
|
/*!50003 DROP PROCEDURE IF EXISTS `delete_data` */;
|
|
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
|
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
|
|
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
|
|
/*!50003 SET character_set_client = utf8mb4 */ ;
|
|
/*!50003 SET character_set_results = utf8mb4 */ ;
|
|
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
|
|
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
|
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`ds`@`localhost` PROCEDURE `delete_data`()
|
|
BEGIN
|
|
DECLARE shipcall_id_var int;
|
|
DECLARE done INT DEFAULT FALSE;
|
|
|
|
DECLARE shipcall_iter CURSOR FOR
|
|
SELECT shipcall.id FROM shipcall
|
|
LEFT JOIN times ON
|
|
times.shipcall_id = shipcall.id AND times.participant_type = 8
|
|
WHERE
|
|
-- ARRIVAL
|
|
(type = 1 AND GREATEST(shipcall.eta, COALESCE(times.eta_berth, 0)) <= CURRENT_DATE() - INTERVAL 1 MONTH) OR
|
|
-- DEPARTURE / SHIFTING
|
|
(type != 1 AND GREATEST(shipcall.etd, COALESCE(times.etd_berth, 0)) <= CURRENT_DATE() - INTERVAL 1 MONTH);
|
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
|
|
|
OPEN shipcall_iter;
|
|
|
|
delete_loop: LOOP
|
|
FETCH shipcall_iter INTO shipcall_id_var;
|
|
IF done THEN
|
|
LEAVE delete_loop;
|
|
END IF;
|
|
DELETE FROM shipcall_participant_map WHERE shipcall_id = shipcall_id_var;
|
|
DELETE FROM shipcall_tug_map WHERE shipcall_id = shipcall_id_var;
|
|
DELETE FROM times WHERE shipcall_id = shipcall_id_var;
|
|
DELETE FROM history WHERE shipcall_id = shipcall_id_var;
|
|
DELETE FROM shipcall WHERE id = shipcall_id_var;
|
|
END LOOP;
|
|
CLOSE shipcall_iter;
|
|
END ;;
|
|
DELIMITER ;
|
|
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
|
/*!50003 SET character_set_client = @saved_cs_client */ ;
|
|
/*!50003 SET character_set_results = @saved_cs_results */ ;
|
|
/*!50003 SET collation_connection = @saved_col_connection */ ;
|
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
|
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
|
|
|
-- Dump completed on 2025-11-17 8:26:36
|