diff options
Diffstat (limited to 'server/src/database/schema.cppm')
| -rw-r--r-- | server/src/database/schema.cppm | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/server/src/database/schema.cppm b/server/src/database/schema.cppm new file mode 100644 index 0000000..a34edef --- /dev/null +++ b/server/src/database/schema.cppm | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | export module routemon:database.schema; | ||
| 2 | |||
| 3 | import std; | ||
| 4 | import :time; | ||
| 5 | |||
| 6 | namespace routemon::database::schema { | ||
| 7 | |||
| 8 | constexpr std::int64_t expected_version = 2; | ||
| 9 | |||
| 10 | enum class rwgps_notification_cause | ||
| 11 | { | ||
| 12 | unknown, | ||
| 13 | created, | ||
| 14 | updated, | ||
| 15 | deleted, | ||
| 16 | added, | ||
| 17 | removed, | ||
| 18 | }; | ||
| 19 | |||
| 20 | auto try_to_string(rwgps_notification_cause c) -> std::optional<std::string>; | ||
| 21 | |||
| 22 | enum class rwgps_notification_item_type | ||
| 23 | { | ||
| 24 | unknown, | ||
| 25 | trip, | ||
| 26 | route, | ||
| 27 | event, | ||
| 28 | event_participant, | ||
| 29 | club_member, | ||
| 30 | authorization, | ||
| 31 | }; | ||
| 32 | |||
| 33 | auto try_to_string(rwgps_notification_item_type t) | ||
| 34 | -> std::optional<std::string>; | ||
| 35 | |||
| 36 | enum rwgps_notification_target_collection_type | ||
| 37 | { | ||
| 38 | unknown, | ||
| 39 | pinned, | ||
| 40 | }; | ||
| 41 | |||
| 42 | auto try_to_string(rwgps_notification_target_collection_type t) | ||
| 43 | -> std::optional<std::string>; | ||
| 44 | |||
| 45 | struct rwgps_notification_target_collection | ||
| 46 | { | ||
| 47 | std::int64_t notification_id = 0; | ||
| 48 | std::int64_t id; | ||
| 49 | rwgps_notification_target_collection_type type; | ||
| 50 | std::optional<std::string> url; | ||
| 51 | }; | ||
| 52 | |||
| 53 | struct rwgps_notification | ||
| 54 | { | ||
| 55 | std::int64_t id = 0; | ||
| 56 | time::timestamp<std::chrono::seconds> rwgps_timestamp; | ||
| 57 | // User that took the action | ||
| 58 | std::int64_t user_id; | ||
| 59 | rwgps_notification_item_type item_type; | ||
| 60 | std::optional<std::int64_t> item_id; | ||
| 61 | // User that owns the item | ||
| 62 | std::optional<std::int64_t> item_user_id; | ||
| 63 | std::optional<std::string> item_url; | ||
| 64 | rwgps_notification_cause action; | ||
| 65 | }; | ||
| 66 | |||
| 67 | } // namespace routemon::database::schema | ||