diff --git a/db.svg b/db.svg deleted file mode 100644 index 8a0ac41..0000000 --- a/db.svg +++ /dev/null @@ -1,494 +0,0 @@ - - - - - - -undefined - -db.sqlite - - -user - -user - -id* -integer -name -text -pw -text -deleted -boolean -last_access -datetime -dob -text -weight -text -sex -text -dirty_thirty -text -dirty_dozen -text -member_since_date -text -birthdate -text -mail -text -nickname -text -notes -text -phone -text -address -text -family_id -integer -membership_pdf -blob - - - -family - -family - -id* -integer - - - -user->family - - - - - -trip_details - -trip_details - -id* -integer -planned_starting_time -text -max_people -integer -day -text -notes -text -trip_type_id -integer -allow_guests -boolean -always_show -boolean -is_locked -boolean - - - -trip_type - -trip_type - -id* -integer -name -text -desc -text -question -text -icon -text - - - -trip_details->trip_type - - - - - -planned_event - -planned_event - -id* -integer -name -text -planned_amount_cox -integer unsigned -trip_details_id -integer -created_at -text - - - -planned_event->trip_details - - - - - -trip - -trip - -id* -integer -cox_id -integer -trip_details_id -integer -planned_event_id -integer -created_at -text - - - -trip->user - - - - - -trip->trip_details - - - - - -trip->planned_event - - - - - -location - -location - -id* -integer -name -text - - - -boat - -boat - -id* -integer -name -text -amount_seats -integer -location_id -integer -owner -integer -year_built -integer -boatbuilder -text -default_shipmaster_only_steering -boolean -skull -boolean -external -boolean -default_destination -text - - - -boat->user - - - - - -boat->location - - - - - -logbook_type - -logbook_type - -id* -integer -name -text - - - -log - -log - -id* -integer -msg -text -created_at -datetime - - - -boat_damage - -boat_damage - -id* -integer -boat_id -integer -desc -text -user_id_created -integer -created_at -datetime -user_id_fixed -integer -fixed_at -datetime -user_id_verified -integer -verified_at -datetime -lock_boat -boolean - - - -boat_damage->user - - - - - -boat_damage->user - - - - - -boat_damage->user - - - - - -boat_damage->boat - - - - - -user_trip - -user_trip - -user_id -integer -user_note -text -trip_details_id -integer -created_at -text - - - -user_trip->user - - - - - -user_trip->trip_details - - - - - -rower - -rower - -logbook_id -integer -rower_id -integer - - - -rower->user - - - - - -logbook - -logbook - -id* -integer -boat_id -integer -shipmaster -integer -steering_person -integer -shipmaster_only_steering -boolean -departure -datetime -arrival -datetime -destination -text -distance_in_km -integer -comments -text -logtype -integer - - - -rower->logbook - - - - - -logbook->user - - - - - -logbook->user - - - - - -logbook->boat - - - - - -logbook->logbook_type - - - - - -role - -role - -id* -integer -name -text - - - -user_role - -user_role - -user_id -integer -role_id -integer - - - -user_role->user - - - - - -user_role->role - - - - - -boathouse - -boathouse - -id* -integer -boat_id -integer -aisle -text -side -text -level -integer - - - -boathouse->boat - - - - - -notification - -notification - -id* -integer -user_id -integer -message -text -read_at -datetime -created_at -datetime -category -text -link -text - - - -notification->user - - - - - diff --git a/doc/db/README.md b/doc/db/README.md new file mode 100644 index 0000000..ca909b1 --- /dev/null +++ b/doc/db/README.md @@ -0,0 +1,54 @@ +# Database + +Since the database stabilized quite well over the last months/years, hopefully it will not change that much in the future. +Thus, here is the current (October '24) model and the reasoning behind it: + +- **User** +![](./user.svg) + +- All user-relevant fields are stored in `User`. +- `Role` (and its associative table `UserRole`) map current roles the user has. This is used for e.g. permissions (`Vorstand`, `Admin`, `cox`, ... roles) and fee calculation (`Donau Linz`, `scheckbuch`, `Rennjugend`). +- `Family` specifies, well, a family. Currently only used for fee calculation. + +- **Planned rowing adventures :-)** +![](./planned.svg) + +There are 2 main types: + 1. **Trips:** Trips can be created by every cox. They are "simple", every-day trips. + 2. **Events:** Events can be created by everyone who has the `manage_events` role. They are used if multiple coxes are needed, e.g. for "Fetzenfahrt", "Anrudern", .... Additionally, events are shown in public calendar (e.g. on the website). + +`TripDetails` extracts the common data for both Trips and Events. +Rower can register using the `UserTrip` table. +This table expects either... + - a `user_id`, if a person who has an account registers to the trip/event + - a `user_note`, if the cox of a trip, or a `manage_events` user of an event wants to add a guest which has no account + +- **Logbook** +![](./logbook.svg) + +If `arrival` is NULL, the boat is assumed to still be on the water. +There are a few `LogbookType`s: +- `Wanderfahrt`: Used to check if a user has accomplished their `Fahrtenabzeichen` in the current year. +- `Regatta` + +If the number of users entered is less than the boat's maximum capacity, the remaining spaces will be automatically assigned to guests. + +- **Boat** +![](./boat.svg) + +- **Trailer** +![](./trailer.svg) + +- **Fetching** +![](./fetching.svg) + +This tables are used to automatically fetch data (every hour). Currently we have: +- `Waterlevel` which fetches the current waterlevel in Linz from hydro (with their explicit permission :-)) +- `Weather` weather data from *Open Weather* + +- **Misc** +![](./misc.svg) + +- **Log:** Logs "interesting" activities, to be viewed in the web ui +- **Notification** +- **Distance:** Default distances of certain common targets diff --git a/doc/db/boat.mermaid b/doc/db/boat.mermaid new file mode 100644 index 0000000..8a41cd0 --- /dev/null +++ b/doc/db/boat.mermaid @@ -0,0 +1,69 @@ +classDiagram + class Boat { + +int id + +string name + +int amount_seats + +int location_id + +int owner + +int year_built + +string boatbuilder + +bool default_shipmaster_only_steering + +bool convert_handoperated_possible + +string default_destination + +bool skull + +bool external + +bool deleted + } + + class Location { + +int id + +string name + } + + class Boathouse { + +int id + +int boat_id + +string aisle + +string side + +int level + } + + class BoatDamage { + +int id + +int boat_id + +string desc + +int user_id_created + +datetime created_at + +int user_id_fixed + +datetime fixed_at + +int user_id_verified + +datetime verified_at + +bool lock_boat + } + + class BoatReservation { + +int id + +int boat_id + +date start_date + +date end_date + +string time_desc + +string usage + +int user_id_applicant + +int user_id_confirmation + +datetime created_at + } + + class User { + ... + } + + Boat "*" -- "1" User : owner + Boat "*" -- "1" Location + Boathouse "*" -- "1" Boat + BoatDamage "*" -- "1" Boat + BoatDamage "*" -- "1" User : created_by + BoatDamage "*" -- "0..1" User : fixed_by + BoatDamage "*" -- "0..1" User : verified_by + BoatReservation "*" -- "1" Boat + BoatReservation "*" -- "1" User : applicant + BoatReservation "*" -- "0..1" User : confirmed_by diff --git a/doc/db/boat.svg b/doc/db/boat.svg new file mode 100644 index 0000000..0b518d1 --- /dev/null +++ b/doc/db/boat.svg @@ -0,0 +1 @@ +
owner
*
1
*
1
*
1
*
1
created_by
*
1
fixed_by
*
0..1
verified_by
*
0..1
*
1
applicant
*
1
confirmed_by
*
0..1
Boat
+int id
+string name
+int amount_seats
+int location_id
+int owner
+int year_built
+string boatbuilder
+bool default_shipmaster_only_steering
+bool convert_handoperated_possible
+string default_destination
+bool skull
+bool external
+bool deleted
Location
+int id
+string name
Boathouse
+int id
+int boat_id
+string aisle
+string side
+int level
BoatDamage
+int id
+int boat_id
+string desc
+int user_id_created
+datetime created_at
+int user_id_fixed
+datetime fixed_at
+int user_id_verified
+datetime verified_at
+bool lock_boat
BoatReservation
+int id
+int boat_id
+date start_date
+date end_date
+string time_desc
+string usage
+int user_id_applicant
+int user_id_confirmation
+datetime created_at
User
...
\ No newline at end of file diff --git a/doc/db/fetching.mermaid b/doc/db/fetching.mermaid new file mode 100644 index 0000000..ce04f8b --- /dev/null +++ b/doc/db/fetching.mermaid @@ -0,0 +1,22 @@ +classDiagram + class Waterlevel { + +int id + +date day + +string time + +int max + +int min + +int mittel + +int tumax + +int tumin + +int tumittel + } + + class Weather { + +int id + +date day + +float max_temp + +float wind_gust + +float rain_mm + } + + diff --git a/doc/db/fetching.svg b/doc/db/fetching.svg new file mode 100644 index 0000000..bdce078 --- /dev/null +++ b/doc/db/fetching.svg @@ -0,0 +1 @@ +
Waterlevel
+int id
+date day
+string time
+int max
+int min
+int mittel
+int tumax
+int tumin
+int tumittel
Weather
+int id
+date day
+float max_temp
+float wind_gust
+float rain_mm
\ No newline at end of file diff --git a/doc/db/logbook.mermaid b/doc/db/logbook.mermaid new file mode 100644 index 0000000..25f7f87 --- /dev/null +++ b/doc/db/logbook.mermaid @@ -0,0 +1,38 @@ +classDiagram + class Logbook { + +int id + +int boat_id + +int shipmaster + +int steering_person + +bool shipmaster_only_steering + +datetime departure + +datetime arrival + +string destination + +int distance_in_km + +string comments + +int logtype + } + + class LogbookType { + +int id + +string name + } + + class Rower { + +int logbook_id + +int rower_id + } + + class User { + ... + } + + class Boat { + ... + } + + Logbook "*" -- "1" Boat + Logbook "*" -- "1" User : shipmaster + Logbook "*" -- "1" LogbookType + Rower "*" -- "1" Logbook + Rower "*" -- "1" User diff --git a/doc/db/logbook.svg b/doc/db/logbook.svg new file mode 100644 index 0000000..9ba5f3d --- /dev/null +++ b/doc/db/logbook.svg @@ -0,0 +1 @@ +
*
1
shipmaster
*
1
*
1
*
1
*
1
Logbook
+int id
+int boat_id
+int shipmaster
+int steering_person
+bool shipmaster_only_steering
+datetime departure
+datetime arrival
+string destination
+int distance_in_km
+string comments
+int logtype
LogbookType
+int id
+string name
Rower
+int logbook_id
+int rower_id
User
...
Boat
...
\ No newline at end of file diff --git a/doc/db/misc.mermaid b/doc/db/misc.mermaid new file mode 100644 index 0000000..da0923d --- /dev/null +++ b/doc/db/misc.mermaid @@ -0,0 +1,30 @@ +classDiagram + class Log { + +int id + +string msg + +datetime created_at + } + + class Notification { + +int id + +int user_id + +string message + +datetime read_at + +datetime created_at + +string category + +string action_after_reading + +string link + } + + class Distance { + +int id + +string destination + +int distance_in_km + } + + class User { + ... + } + + %% Relationships + Notification "*" -- "1" User diff --git a/doc/db/misc.svg b/doc/db/misc.svg new file mode 100644 index 0000000..b09b519 --- /dev/null +++ b/doc/db/misc.svg @@ -0,0 +1 @@ +
*
1
Log
+int id
+string msg
+datetime created_at
Notification
+int id
+int user_id
+string message
+datetime read_at
+datetime created_at
+string category
+string action_after_reading
+string link
Distance
+int id
+string destination
+int distance_in_km
User
...
\ No newline at end of file diff --git a/doc/db/planned.mermaid b/doc/db/planned.mermaid new file mode 100644 index 0000000..9de1f14 --- /dev/null +++ b/doc/db/planned.mermaid @@ -0,0 +1,56 @@ +classDiagram + class TripType { + +int id + +string name + +string desc + +string question + +string icon + } + + class TripDetails { + +int id + +string planned_starting_time + +int max_people + +string day + +bool allow_guests + +string notes + +bool always_show + +bool is_locked + +int trip_type_id + } + + class PlannedEvent { + +int id + +string name + +int planned_amount_cox + +int trip_details_id + +string created_at + } + + class Trip { + +int id + +int cox_id + +int trip_details_id + +int planned_event_id + +string created_at + } + + class UserTrip { + +int user_id + +string user_note + +int trip_details_id + +string created_at + } + + class User { + ... + } + + + TripType "1" -- "*" TripDetails + TripDetails "1" -- "*" PlannedEvent + Trip "*" -- "1" TripDetails + Trip "*" -- "1" PlannedEvent + UserTrip "*" -- "1" TripDetails + Trip "*" -- "1" User : cox + UserTrip "*" -- "1" User diff --git a/doc/db/planned.svg b/doc/db/planned.svg new file mode 100644 index 0000000..079a46e --- /dev/null +++ b/doc/db/planned.svg @@ -0,0 +1 @@ +
1
*
1
*
*
1
*
1
*
1
cox
*
1
*
1
TripType
+int id
+string name
+string desc
+string question
+string icon
TripDetails
+int id
+string planned_starting_time
+int max_people
+string day
+bool allow_guests
+string notes
+bool always_show
+bool is_locked
+int trip_type_id
PlannedEvent
+int id
+string name
+int planned_amount_cox
+int trip_details_id
+string created_at
Trip
+int id
+int cox_id
+int trip_details_id
+int planned_event_id
+string created_at
UserTrip
+int user_id
+string user_note
+int trip_details_id
+string created_at
User
...
\ No newline at end of file diff --git a/doc/db/recreate.sh b/doc/db/recreate.sh new file mode 100755 index 0000000..a81041d --- /dev/null +++ b/doc/db/recreate.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find . -name "*.mermaid" -type f -exec sh -c 'mmdc -i "$1" -o "${1%.mermaid}.svg" -b transparent -t dark' sh {} \; diff --git a/doc/db/trailer.mermaid b/doc/db/trailer.mermaid new file mode 100644 index 0000000..670b171 --- /dev/null +++ b/doc/db/trailer.mermaid @@ -0,0 +1,25 @@ +classDiagram + class Trailer { + +int id + +string name + } + + class TrailerReservation { + +int id + +int trailer_id + +date start_date + +date end_date + +string time_desc + +string usage + +int user_id_applicant + +int user_id_confirmation + +datetime created_at + } + + class User { + ... + } + + TrailerReservation "*" -- "1" Trailer + TrailerReservation "*" -- "1" User : applicant + TrailerReservation "*" -- "0..1" User : confirmed_by diff --git a/doc/db/trailer.svg b/doc/db/trailer.svg new file mode 100644 index 0000000..d9db30f --- /dev/null +++ b/doc/db/trailer.svg @@ -0,0 +1 @@ +
*
1
applicant
*
1
confirmed_by
*
0..1
Trailer
+int id
+string name
TrailerReservation
+int id
+int trailer_id
+date start_date
+date end_date
+string time_desc
+string usage
+int user_id_applicant
+int user_id_confirmation
+datetime created_at
User
...
\ No newline at end of file diff --git a/doc/db/user.mermaid b/doc/db/user.mermaid new file mode 100644 index 0000000..85dbac6 --- /dev/null +++ b/doc/db/user.mermaid @@ -0,0 +1,41 @@ +classDiagram + class User { + +int id + +string name + +string pw + +bool deleted + +datetime last_access + +string dob + +string weight + +string sex + +string dirty_thirty + +string dirty_dozen + +string member_since_date + +string birthdate + +string mail + +string nickname + +string notes + +string phone + +string address + +int family_id + +blob membership_pdf + +string user_token + } + + class Family { + +int id + } + + class Role { + +int id + +string name + } + + class UserRole { + +int user_id + +int role_id + } + + User "1" -- "*" UserRole + Role "1" -- "*" UserRole + User "1" -- "0..1" Family diff --git a/doc/db/user.svg b/doc/db/user.svg new file mode 100644 index 0000000..f635599 --- /dev/null +++ b/doc/db/user.svg @@ -0,0 +1 @@ +
1
*
1
*
1
0..1
User
+int id
+string name
+string pw
+bool deleted
+datetime last_access
+string dob
+string weight
+string sex
+string dirty_thirty
+string dirty_dozen
+string member_since_date
+string birthdate
+string mail
+string nickname
+string notes
+string phone
+string address
+int family_id
+blob membership_pdf
+string user_token
Family
+int id
Role
+int id
+string name
UserRole
+int user_id
+int role_id
\ No newline at end of file