diff options
| author | Rutger Broekhoff | 2026-11-30 11:47:36 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-11-30 11:47:36 +0100 |
| commit | 02475e05ccd1aa15c6a6163834f28bfebbef796f (patch) | |
| tree | 6bc6f453f07dc76f763310e1e5eade9a3e1115b7 /server/migrations | |
| parent | 5732f6c14618f50ffaf315b93795340219a67c66 (diff) | |
| download | routemon-02475e05ccd1aa15c6a6163834f28bfebbef796f.tar.gz routemon-02475e05ccd1aa15c6a6163834f28bfebbef796f.zip | |
RWGPS webhook and such
Diffstat (limited to 'server/migrations')
| -rw-r--r-- | server/migrations/1_init_up.sql | 13 | ||||
| -rw-r--r-- | server/migrations/2_kaas_up.sql | 23 | ||||
| -rw-r--r-- | server/migrations/2_rwgps_up.sql | 22 |
3 files changed, 29 insertions, 29 deletions
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 @@ | |||
| 1 | BEGIN; | 1 | CREATE TABLE migration ( |
| 2 | at_most_one_row INTEGER UNIQUE DEFAULT 1, | ||
| 3 | version INTEGER NOT NULL, | ||
| 4 | -- This table should have at most one row. | ||
| 5 | CHECK (at_most_one_row = 1) | ||
| 6 | ) STRICT; | ||
| 2 | 7 | ||
| 3 | CREATE TABLE migration (version); | 8 | INSERT INTO migration (version) VALUES (0); |
| 4 | |||
| 5 | INSERT INTO migration VALUES (1); | ||
| 6 | |||
| 7 | COMMIT; | ||
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 @@ | |||
| 1 | BEGIN; | ||
| 2 | |||
| 3 | -- TODO enable strict mode so that primary key is automatically enforced to not be NULL | ||
| 4 | CREATE TABLE received_route ( | ||
| 5 | id INTEGER PRIMARY KEY, | ||
| 6 | |||
| 7 | received_route_source route_source NOT NULL, | ||
| 8 | recieved_route_strava_id TEXT, | ||
| 9 | |||
| 10 | -- ON DELETE what? | ||
| 11 | FOREIGN KEY (received_route_source_id) REFERENCES received_route_source (id), | ||
| 12 | CHECK (received_route_source IN ('gpx_upload', 'strava', 'rwgps')), | ||
| 13 | CHECK ((received_route_source = 'strava') = (received_route_strava_id IS NULL)) | ||
| 14 | ); | ||
| 15 | |||
| 16 | CREATE TABLE received_route_linestring ( | ||
| 17 | received_route_id INT NOT NULL, | ||
| 18 | linestring BLOB NOT NULL, | ||
| 19 | |||
| 20 | FOREIGN KEY (received_route_id) REFERENCES received_route (id) | ||
| 21 | ); | ||
| 22 | |||
| 23 | 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 @@ | |||
| 1 | CREATE TABLE rwgps_notification ( | ||
| 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| 3 | rwgps_timestamp TEXT NOT NULL, | ||
| 4 | user_id INTEGER NOT NULL, | ||
| 5 | item_type TEXT, -- NULL if unknown | ||
| 6 | item_id INTEGER, | ||
| 7 | item_user_id INTEGER, | ||
| 8 | item_url TEXT, | ||
| 9 | action_ TEXT, -- NULL if unknown | ||
| 10 | CHECK (rwgps_timestamp IS strftime('%FT%TZ', rwgps_timestamp)), | ||
| 11 | CHECK (item_type IN ('trip', 'route', 'event', 'event_participant', 'club_member', 'authorization')), | ||
| 12 | CHECK (action_ IN ('created', 'updated', 'deleted', 'added', 'removed')) | ||
| 13 | ) STRICT; | ||
| 14 | |||
| 15 | CREATE TABLE rwgps_notification_target_collection ( | ||
| 16 | notification_id INTEGER PRIMARY KEY, | ||
| 17 | id INTEGER NOT NULL, | ||
| 18 | type_ TEXT, -- NULL if unknown | ||
| 19 | url TEXT, | ||
| 20 | CHECK (type_ IN ('pinned')), | ||
| 21 | FOREIGN KEY (notification_id) REFERENCES rwgps_notification (id) | ||
| 22 | ) STRICT; | ||