diff --git a/misc/create_schema.sql b/misc/create_schema.sql index f405152..6004405 100644 --- a/misc/create_schema.sql +++ b/misc/create_schema.sql @@ -16,22 +16,36 @@ CREATE TABLE `ship` ( `name` varchar(45) DEFAULT NULL, `imo` int(11) DEFAULT NULL, `callsign` varchar(8) DEFAULT NULL, + `length` FLOAT NULL DEFAULT NULL, + `width` FLOAT NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `shipcall` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `ship_id` int(11) DEFAULT NULL, - `arrival_berth_id` int(11) DEFAULT NULL, - `departure_berth_id` int(11) DEFAULT NULL, - `type` tinyint(4) DEFAULT NULL, - `eta` datetime DEFAULT NULL, - `voyage` varchar(16) DEFAULT NULL, - `etd` datetime DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Incoming, outgoing or moving to another berth '; - + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `ship_id` INT(11) NULL DEFAULT NULL, + `type` TINYINT(4) NULL DEFAULT NULL, + `eta` DATETIME NULL DEFAULT NULL, + `voyage` VARCHAR(16) NULL DEFAULT NULL, + `etd` DATETIME NULL DEFAULT NULL, + `arrival_berth_id` INT(10) NULL DEFAULT NULL, + `departure_berth_id` INT(10) NULL DEFAULT NULL, + `tug_required` BIT(1) NULL DEFAULT NULL, + `pilot_required` BIT(1) NULL DEFAULT NULL, + `flags` INT(10) UNSIGNED NULL DEFAULT 0, + `pier_side` BIT(1) NULL DEFAULT NULL, + `bunkering` BIT(1) NULL DEFAULT NULL, + `replenishing` BIT(1) NULL DEFAULT NULL, + `draft` FLOAT NULL DEFAULT NULL, + `tidal_window_from` DATETIME NULL DEFAULT NULL, + `tidal_window_tp` DATETIME NULL DEFAULT NULL, + `rain_sensitive_cargo` BIT(1) NULL DEFAULT b'0', + `recommended_tugs` INT(11) NULL DEFAULT 0, + PRIMARY KEY (`id`) +) +COMMENT='Incoming, outgoing or moving to another berth' +ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE `times` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -60,22 +74,27 @@ CREATE TABLE `user` ( CREATE TABLE `participant` ( - `id` int(10) 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, - `flags` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`) + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(128) NULL DEFAULT NULL, + `street` VARCHAR(128) NULL DEFAULT NULL, + `postal_code` VARCHAR(5) NULL DEFAULT NULL, + `city` VARCHAR(64) NULL DEFAULT NULL, + `roles` INT(10) UNSIGNED NULL DEFAULT 0 COMMENT 'Bitarray of assigned roles', + `flags` INT(10) UNSIGNED NULL DEFAULT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='An organization taking part'; CREATE TABLE `berth` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name1` varchar(128) DEFAULT NULL, - `name2` varchar(128) DEFAULT NULL, - PRIMARY KEY(`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Place of ship for a ship call'; + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(128) NULL DEFAULT NULL COMMENT 'Descriptive name', + `participant_id` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'If berth belongs to a participant, reference it here', + `lock` BIT(1) NULL DEFAULT NULL COMMENT 'The lock must be used', + PRIMARY KEY (`id`) +) +COMMENT='Berth of ship for a ship call' +ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 +; CREATE TABLE `shipcall_participant_map` ( @@ -84,3 +103,14 @@ CREATE TABLE `shipcall_participant_map` ( `participant_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Associates a participant with a shipcall'; + + +CREATE TABLE `shipcall_tug_map` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `shipcall_id` INT(11) NOT NULL COMMENT 'Ref to ship call', + `ship_id` INT(11) NOT NULL COMMENT 'Ref to ship (that is a tug)', + PRIMARY KEY (`id`) +) +COMMENT='Mapping table that assigns tugs to a ship call' +ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 +; diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py index ee89185..6af3f86 100644 --- a/src/server/BreCal/__init__.py +++ b/src/server/BreCal/__init__.py @@ -40,9 +40,7 @@ def create_app(test_config=None): app.register_blueprint(berths.bp) logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') - local_db.initPool() - logging.info('App started') return app