From cb2493eca9d129ca32880b989ea285c29c3a95d4 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Mon, 26 Oct 2009 13:33:48 +0000
Subject: [PATCH] * Store the jobset's nixExprPath and nixExprInput fields in a
 build to   allow it to be cloned (re-executed with modified inputs) later and
   to provide some traceability.

---
 doc/dev-notes.txt              |  2 ++
 src/lib/Hydra/Schema/Builds.pm | 18 ++++++++++++++++--
 src/script/hydra_scheduler.pl  |  2 ++
 src/sql/hydra.sql              |  6 ++++++
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/doc/dev-notes.txt b/doc/dev-notes.txt
index e3bc6694..8e95e098 100644
--- a/doc/dev-notes.txt
+++ b/doc/dev-notes.txt
@@ -100,6 +100,8 @@
   alter table ViewJobs drop column mayFail;
   alter table ViewJobs add column autorelease integer not null default 0;
 
+  alter table Builds add column nixExprInput text;
+  alter table Builds add column nixExprPath text;
 
   
 * Job selection:
diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm
index 6d8f0ba1..8160d515 100644
--- a/src/lib/Hydra/Schema/Builds.pm
+++ b/src/lib/Hydra/Schema/Builds.pm
@@ -122,6 +122,20 @@ __PACKAGE__->add_columns(
   },
   "iscurrent",
   { data_type => "integer", default_value => 0, is_nullable => 1, size => undef },
+  "nixexprinput",
+  {
+    data_type => "text",
+    default_value => undef,
+    is_nullable => 1,
+    size => undef,
+  },
+  "nixexprpath",
+  {
+    data_type => "text",
+    default_value => undef,
+    is_nullable => 1,
+    size => undef,
+  },
 );
 __PACKAGE__->set_primary_key("id");
 __PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
@@ -172,8 +186,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.04999_09 @ 2009-10-23 16:56:03
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L+BuQvxJL8gG7jib1AAIrw
+# Created by DBIx::Class::Schema::Loader v0.04999_09 @ 2009-10-26 14:22:27
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qbNPA5NkENlZXILuE3OGkA
 
 use Hydra::Helper::Nix;
 
diff --git a/src/script/hydra_scheduler.pl b/src/script/hydra_scheduler.pl
index 0ab3e81a..496c875d 100755
--- a/src/script/hydra_scheduler.pl
+++ b/src/script/hydra_scheduler.pl
@@ -304,6 +304,8 @@ sub checkJob {
             , outpath => $outPath
             , system => $job->{system}
             , iscurrent => 1
+            , nixexprinput => $jobset->nixexprinput
+            , nixexprpath => $jobset->nixexprpath
             });
 
         print "added to queue as build ", $build->id, "\n";
diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql
index 7e8e8fb1..7cd8f070 100644
--- a/src/sql/hydra.sql
+++ b/src/sql/hydra.sql
@@ -134,6 +134,12 @@ create table Builds (
     maintainers   text, -- meta.maintainers (concatenated, comma-separated)
 
     isCurrent     integer default 0,
+
+    -- Copy of the nixExprInput/nixExprPath fields of the jobset that
+    -- instantiated this build.  Needed if we want to clone this
+    -- build.
+    nixExprInput  text,
+    nixExprPath   text,
     
     foreign key   (project) references Projects(name) on update cascade,
     foreign key   (project, jobset) references Jobsets(project, name) on update cascade,