From 02475e05ccd1aa15c6a6163834f28bfebbef796f Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 30 Nov 2026 11:47:36 +0100 Subject: RWGPS webhook and such --- server/migrations/1_init_up.sql | 13 +++++++------ server/migrations/2_kaas_up.sql | 23 ----------------------- server/migrations/2_rwgps_up.sql | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 server/migrations/2_kaas_up.sql create mode 100644 server/migrations/2_rwgps_up.sql (limited to 'server/migrations') diff --git a/server/migrations/1_init_up.sql b/server/migrations/1_init_up.sql index 7edb398..8400f8d 100644 --- a/server/migrations/1_init_up.sql +++ b/server/migrations/1_init_up.sql @@ -1,7 +1,8 @@ -BEGIN; +CREATE TABLE migration ( + at_most_one_row INTEGER UNIQUE DEFAULT 1, + version INTEGER NOT NULL, + -- This table should have at most one row. + CHECK (at_most_one_row = 1) +) STRICT; -CREATE TABLE migration (version); - -INSERT INTO migration VALUES (1); - -COMMIT; +INSERT INTO migration (version) VALUES (0); diff --git a/server/migrations/2_kaas_up.sql b/server/migrations/2_kaas_up.sql deleted file mode 100644 index 0c7837a..0000000 --- a/server/migrations/2_kaas_up.sql +++ /dev/null @@ -1,23 +0,0 @@ -BEGIN; - --- TODO enable strict mode so that primary key is automatically enforced to not be NULL -CREATE TABLE received_route ( - id INTEGER PRIMARY KEY, - - received_route_source route_source NOT NULL, - recieved_route_strava_id TEXT, - - -- ON DELETE what? - FOREIGN KEY (received_route_source_id) REFERENCES received_route_source (id), - CHECK (received_route_source IN ('gpx_upload', 'strava', 'rwgps')), - CHECK ((received_route_source = 'strava') = (received_route_strava_id IS NULL)) -); - -CREATE TABLE received_route_linestring ( - received_route_id INT NOT NULL, - linestring BLOB NOT NULL, - - FOREIGN KEY (received_route_id) REFERENCES received_route (id) -); - -COMMIT; diff --git a/server/migrations/2_rwgps_up.sql b/server/migrations/2_rwgps_up.sql new file mode 100644 index 0000000..569479b --- /dev/null +++ b/server/migrations/2_rwgps_up.sql @@ -0,0 +1,22 @@ +CREATE TABLE rwgps_notification ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + rwgps_timestamp TEXT NOT NULL, + user_id INTEGER NOT NULL, + item_type TEXT, -- NULL if unknown + item_id INTEGER, + item_user_id INTEGER, + item_url TEXT, + action_ TEXT, -- NULL if unknown + CHECK (rwgps_timestamp IS strftime('%FT%TZ', rwgps_timestamp)), + CHECK (item_type IN ('trip', 'route', 'event', 'event_participant', 'club_member', 'authorization')), + CHECK (action_ IN ('created', 'updated', 'deleted', 'added', 'removed')) +) STRICT; + +CREATE TABLE rwgps_notification_target_collection ( + notification_id INTEGER PRIMARY KEY, + id INTEGER NOT NULL, + type_ TEXT, -- NULL if unknown + url TEXT, + CHECK (type_ IN ('pinned')), + FOREIGN KEY (notification_id) REFERENCES rwgps_notification (id) +) STRICT; -- cgit v1.3.1