aboutsummaryrefslogtreecommitdiff
path: root/src/schema.sql
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-10-21 22:43:16 +0100
committerChristopher Baines <mail@cbaines.net>2019-12-28 19:54:38 +0000
commit267230d027652161c4bc138711b7a0c9b65329ad (patch)
tree03bf8cd11ebfe7d01544cb48a904661b763326fe /src/schema.sql
parent5c5790ad21d88599bb07dd9669708d8b58a47124 (diff)
downloadcuirass-267230d027652161c4bc138711b7a0c9b65329ad.tar
cuirass-267230d027652161c4bc138711b7a0c9b65329ad.tar.gz
Support publishing build events
Add a table to store events, which have a type and a JSON blob. These can be used to record changes, this commit inserts events when new builds are created, and when the status of builds change. The EventsOutbox table is then used to track when events have been sent out. This is done through the new cuirass-send-events script. * Makefile.am (bin_SCRIPTS): Add bin/cuirass-send-events. (dist_pkgmodule_DATA): Add src/cuirass/send-events.scm. (dist_sql_DATA): Add src/sql/upgrade-5.sql. (EXTRA_DIST): bin/cuirass-send-events.in. (bin/cuirass-send-events): New rule. * bin/cuirass-send-events.in: New file. * src/cuirass/send-events.scm: New file. * src/sql/upgrade-5.sql: New file. * src/cuirass/database.scm (changes-count): New procedure. (db-update-build-status!): Call db-add-event after updating the build status. (db-add-event): New procedure. (db-add-build): Insert an event when a new build is inserted. (db-delete-events-with-ids-<=-to): New procedure. * src/schema.sql (Events): New table.
Diffstat (limited to 'src/schema.sql')
-rw-r--r--src/schema.sql7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/schema.sql b/src/schema.sql
index a9e4a6a..cd67530 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -64,6 +64,13 @@ CREATE TABLE Builds (
FOREIGN KEY (evaluation) REFERENCES Evaluations (id)
);
+CREATE TABLE Events (
+ id INTEGER PRIMARY KEY,
+ type TEXT NOT NULL,
+ timestamp INTEGER NOT NULL,
+ event_json TEXT NOT NULL
+);
+
-- Create indexes to speed up common queries, in particular those
-- corresponding to /api/latestbuilds and /api/queue HTTP requests.
CREATE INDEX Builds_index ON Builds(job_name, system, status ASC, timestamp ASC, derivation, evaluation, stoptime DESC);