User management with native gui and further improvements

This commit is contained in:
2026-08-17 10:37:19 +02:00
parent 41556cfe73
commit a3c8b4083d
24 changed files with 1004 additions and 159 deletions
+70 -30
View File
@@ -3,6 +3,12 @@
/* MariaDB Scheme
Version: 1 */
/* TODO
- check all values if unsigned can be used or not
- implement foreign keys where possible
- rename provisions to provision(?)
*/
/* User
userid is signed because nevative values are required for settings
The user table must not be writeable by the webgui user!
@@ -58,6 +64,28 @@ CREATE TABLE dropdown (
PRIMARY KEY (ddid, ddval)
) ENGINE=InnoDB;
CREATE TABLE company (
compid smallint(6) NOT NULL AUTO_INCREMENT,
compname varchar(60) NOT NULL,
comptype tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
comptype2 tinyint(3) UNSIGNED DEFAULT NULL,
shortname varchar(20) DEFAULT NULL,
street varchar(40),
zip varchar(10),
city varchar(30),
country varchar(30),
contact varchar(30),
phone varchar(30),
email varchar(50),
web varchar(40),
customerno varchar(20),
contractno varchar(20),
remarks varchar(150) DEFAULT NULL,
flags set('deleted','historic') DEFAULT NULL,
PRIMARY KEY (compid),
UNIQUE INDEX ix_compname (compname, comptype)
) ENGINE=InnoDB;
CREATE TABLE vessel (
vid smallint(6) NOT NULL AUTO_INCREMENT,
vtype enum('mono','cat','tri') NOT NULL DEFAULT 'mono',
@@ -76,14 +104,16 @@ CREATE TABLE vessel (
shapefile varchar(40) DEFAULT NULL,
sid_default smallint(6) UNSIGNED DEFAULT NULL, -- default storage
remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (vid)
PRIMARY KEY (vid),
FOREIGN KEY fk_vessel_shipyard (shipyard)
REFERENCES company(compid)
) ENGINE=InnoDB;
CREATE TABLE storage (
sid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
vid smallint(6) NOT NULL DEFAULT 1,
sname varchar(40) NOT NULL,
stype tinyint(3) NOT NULL DEFAULT 0,
stype tinyint(3) NOT NULL DEFAULT 0, -- ddid=3
capacity smallint(6) DEFAULT NULL,
capaunit enum('kg','l') DEFAULT NULL,
x smallint(6) UNSIGNED NOT NULL DEFAULT 0,
@@ -148,6 +178,16 @@ CREATE TABLE equipment (
PRIMARY KEY(eid)
) ENGINE=InnoDB;
/*
convert to
sid SMALLINT UNSIGNED NULL,
boxid SMALLINT UNSIGNED NULL,
CHECK (
(sid IS NOT NULL AND boxid IS NULL)
OR
(sid IS NULL AND boxid IS NOT NULL)
)
*/
CREATE TABLE inventory (
invid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
invname varchar(80) NOT NULL,
@@ -161,6 +201,7 @@ CREATE TABLE inventory (
purchdate date DEFAULT NULL,
invcond enum('unknown','excellent','good','fair','bad','repairable','defect') NOT NULL default 'unknown',
remarks varchar(150) DEFAULT NULL,
flags set('ordered','removed','deleted') DEFAULT NULL,
PRIMARY KEY (invid),
INDEX ix_invname (invname)
) ENGINE=InnoDB;
@@ -199,6 +240,7 @@ CREATE table fuse (
UNIQUE INDEX ix_fusenumber (vid, fnumber)
) ENGINE=InnoDB;
-- change vals to decimal(12,4)?
CREATE TABLE measurement (
mid smallint(6) NOT NULL AUTO_INCREMENT,
mname varchar(80) NOT NULL,
@@ -226,8 +268,10 @@ CREATE TABLE provisions (
weight float(5,2) UNSIGNED DEFAULT NULL,
weight_net float(5,2) UNSIGNED DEFAULT NULL,
unit tinyint(3) DEFAULT NULL,
calories smallint(6) UNSIGNED DEFAULT NULL,
storedate date DEFAULT CURRENT_DATE,
shelflife date DEFAULT NULL,
price decimal(12,2) DEFAULT NULL,
remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (provid)
) ENGINE=InnoDB;
@@ -259,38 +303,19 @@ CREATE TABLE docref (
drid int(10) NOT NULL AUTO_INCREMENT,
reftype enum('vessel','box','equipment','project','task','user','company') NOT NULL DEFAULT 'vessel',
docid smallint(6) NOT NULL,
refid smallint(6) NOT NULL,
refid int(10) NOT NULL,
PRIMARY KEY (drid),
UNIQUE INDEX ix_docref (docid, refid),
FOREIGN KEY fx_docref_doc (docid)
UNIQUE INDEX ix_docref (docid, refid, reftype),
FOREIGN KEY fk_docref_doc (docid)
REFERENCES document (docid)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE company (
compid smallint(6) NOT NULL AUTO_INCREMENT,
compname varchar(60) NOT NULL,
comptype tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
comptype2 tinyint(3) UNSIGNED DEFAULT NULL,
shortname varchar(20) DEFAULT NULL,
street varchar(40),
zip varchar(10),
city varchar(30),
country varchar(30),
contact varchar(30),
phone varchar(30),
email varchar(50),
web varchar(40),
customerno varchar(20),
contractno varchar(20),
remarks varchar(150) DEFAULT NULL,
flags set('deleted','historic') DEFAULT NULL,
PRIMARY KEY (compid),
UNIQUE INDEX ix_compname (compname, comptype)
) ENGINE=InnoDB;
/* TODO optional field: plan date, target date, completion date */
/* TODO optional fields: plan date, target date, completion date
interval_hours, last_hours
signalk: operating hours current vs maint every n operating hours in separate
*/
CREATE TABLE maintenance (
maintid int(10) NOT NULL AUTO_INCREMENT,
vid smallint(6) NOT NULL DEFAULT 1,
@@ -332,14 +357,16 @@ CREATE TABLE task (
finished datetime DEFAULT NULL,
responsible smallint(6) NOT NULL,
/* TODO executed_by : company or user? or both? */
PRIMARY KEY (taskid)
PRIMARY KEY (taskid),
FOREIGN KEY fk_task_user (responsible)
REFERENCES user(userid)
) ENGINE=InnoDB;
/* Notes can be assigned to tasks,maintenances and equipment */
CREATE TABLE note (
noteid int(10) NOT NULL AUTO_INCREMENT,
notetype enum('task','maint','equip') NOT NULL DEFAULT 'task',
refid smallint(6) NOT NULL,
refid int(10) NOT NULL,
annotation text NOT NULL,
PRIMARY KEY (noteid)
) ENGINE=InnoDB;
@@ -372,3 +399,16 @@ CREATE TABLE checkgroup (
title varchar(30) NOT NULL,
PRIMARY KEY (groupid)
) ENGINE=InnoDB;
/* Expansion for future use: signalk mapping (just an idea) */
CREATE TABLE signalk (
skid int(10) NOT NULL AUTO_INCREMENT,
vid smallint(6) NOT NULL,
objtype enum('equipment','storage') NOT NULL,
objid int(10) NOT NULL,
datatype enum('engine_hours','tank_level') NOT NULL,
skpath varchar(255) NOT NULL,
PRIMARY KEY (skid),
UNIQUE KEY ix_signalk
(vid, objtype, objid, datatype)
) ENGINE=InnoDB;