summaryrefslogtreecommitdiffstats
path: root/server/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'server/migrations')
-rw-r--r--server/migrations/1_init_up.sql13
-rw-r--r--server/migrations/2_kaas_up.sql23
-rw-r--r--server/migrations/2_rwgps_up.sql22
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 @@
1BEGIN; 1CREATE 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
3CREATE TABLE migration (version); 8INSERT INTO migration (version) VALUES (0);
4
5INSERT INTO migration VALUES (1);
6
7COMMIT;
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 @@
1BEGIN;
2
3-- TODO enable strict mode so that primary key is automatically enforced to not be NULL
4CREATE 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
16CREATE 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
23COMMIT;
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 @@
1CREATE 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
15CREATE 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;