From ab51128ee62b22971ea8b52d550e09d1c38f8ecd Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 27 Jun 2020 19:47:30 +0100 Subject: Support storing when builds are created --- guix-build-coordinator/datastore/sqlite.scm | 14 +++++++++----- sqitch/pg/deploy/builds_created_at.sql | 7 +++++++ sqitch/pg/revert/builds_created_at.sql | 7 +++++++ sqitch/pg/verify/builds_created_at.sql | 7 +++++++ sqitch/sqitch.plan | 1 + sqitch/sqlite/deploy/builds_created_at.sql | 7 +++++++ sqitch/sqlite/revert/builds_created_at.sql | 7 +++++++ sqitch/sqlite/verify/builds_created_at.sql | 7 +++++++ 8 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 sqitch/pg/deploy/builds_created_at.sql create mode 100644 sqitch/pg/revert/builds_created_at.sql create mode 100644 sqitch/pg/verify/builds_created_at.sql create mode 100644 sqitch/sqlite/deploy/builds_created_at.sql create mode 100644 sqitch/sqlite/revert/builds_created_at.sql create mode 100644 sqitch/sqlite/verify/builds_created_at.sql diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index a7ff175..88db088 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -736,7 +736,7 @@ GROUP BY derivations.system"))) (sqlite-prepare db " -SELECT uuid, derivation_name, priority, processed +SELECT uuid, derivation_name, priority, processed, created_at FROM builds WHERE uuid = :uuid"))) @@ -746,7 +746,7 @@ WHERE uuid = :uuid"))) (let ((result (match (sqlite-step statement) - (#(uuid derivation_name priority processed) + (#(uuid derivation_name priority processed created_at) `((uuid . ,uuid) (derivation-name . ,derivation_name) (priority . ,priority) @@ -754,7 +754,11 @@ WHERE uuid = :uuid"))) ((= 0 processed) #f) ((= 1 processed) #t) (else - (error "unknown processed value"))))))))) + (error "unknown processed value")))) + (created-at . ,(if (string? created_at) + (match (strptime "%F %T" created_at) + ((parts _) parts)) + #f))))))) (sqlite-reset statement) result))))) @@ -1781,8 +1785,8 @@ INSERT INTO derivation_outputs (derivation_name, name, output) VALUES " (sqlite-prepare db " -INSERT INTO builds (uuid, derivation_name, priority) -VALUES (:uuid, :derivation_name, :priority)"))) +INSERT INTO builds (uuid, derivation_name, priority, created_at) +VALUES (:uuid, :derivation_name, :priority, datetime('now'))"))) (sqlite-bind-arguments statement diff --git a/sqitch/pg/deploy/builds_created_at.sql b/sqitch/pg/deploy/builds_created_at.sql new file mode 100644 index 0000000..60f6b2a --- /dev/null +++ b/sqitch/pg/deploy/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Deploy guix-build-coordinator:builds_created_at to pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/pg/revert/builds_created_at.sql b/sqitch/pg/revert/builds_created_at.sql new file mode 100644 index 0000000..f49c06b --- /dev/null +++ b/sqitch/pg/revert/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Revert guix-build-coordinator:builds_created_at from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/pg/verify/builds_created_at.sql b/sqitch/pg/verify/builds_created_at.sql new file mode 100644 index 0000000..6dc5cd1 --- /dev/null +++ b/sqitch/pg/verify/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Verify guix-build-coordinator:builds_created_at on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index 1aa3b80..5623d5b 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -16,3 +16,4 @@ derivation_outputs_derivation_name_index 2020-05-10T16:24:05Z Christopher Baines build_results_result_index 2020-05-10T17:27:00Z Christopher Baines # Add an index on build_results.result more_indexes_on_builds_and_derivation_inputs 2020-05-11T08:38:28Z Christopher Baines # Add a couple more indexes build_tags 2020-05-31T13:54:41Z Christopher Baines # Support tagging builds +builds_created_at 2020-06-27T18:30:32Z Christopher Baines # Add builds.created_at diff --git a/sqitch/sqlite/deploy/builds_created_at.sql b/sqitch/sqlite/deploy/builds_created_at.sql new file mode 100644 index 0000000..378fb70 --- /dev/null +++ b/sqitch/sqlite/deploy/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Deploy guix-build-coordinator:builds_created_at to sqlite + +BEGIN; + +ALTER TABLE builds ADD COLUMN created_at TEXT; + +COMMIT; diff --git a/sqitch/sqlite/revert/builds_created_at.sql b/sqitch/sqlite/revert/builds_created_at.sql new file mode 100644 index 0000000..84c2e6a --- /dev/null +++ b/sqitch/sqlite/revert/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Revert guix-build-coordinator:builds_created_at from sqlite + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqlite/verify/builds_created_at.sql b/sqitch/sqlite/verify/builds_created_at.sql new file mode 100644 index 0000000..ee1daf9 --- /dev/null +++ b/sqitch/sqlite/verify/builds_created_at.sql @@ -0,0 +1,7 @@ +-- Verify guix-build-coordinator:builds_created_at on sqlite + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; -- cgit v1.2.3