From d493a58823aed8c556bf795d02207e57718b96c9 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@gnu.org>
Date: Tue, 26 Jul 2016 16:53:57 +0200
Subject: schema: Separate "Derivations" from "Evaluations".

* src/schema.sql (Derivations): New table.
(Evaluations): Remove 'derivation' and 'job_name' columns.  Add 'id'
column.
* src/cuirass/database.scm (db-add-evaluation): Adapt.
(db-get-derivation, db-add-derivation): New procedures.
(evaluation-exists?, db-get-evaluation): Delete.
* bin/evaluate.in (main): Adapt.
* tests/database.scm ("sqlite-exec"): Likewise.
("db-add-derivation", "db-get-derivation"): New tests.
("db-add-evaluation", "db-get-evaluation"): Delete.
---
 src/schema.sql | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'src/schema.sql')

diff --git a/src/schema.sql b/src/schema.sql
index d5c1f00..248f9d2 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -21,12 +21,19 @@ CREATE TABLE Stamps (
 );
 
 CREATE TABLE Evaluations (
-  derivation    TEXT NOT NULL PRIMARY KEY,
-  job_name      TEXT NOT NULL,
+  id            INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
   specification INTEGER NOT NULL,
   FOREIGN KEY (specification) REFERENCES Specifications (id)
 );
 
+CREATE TABLE Derivations (
+  derivation    TEXT NOT NULL,
+  evaluation    INTEGER NOT NULL,
+  job_name      TEXT NOT NULL,
+  PRIMARY KEY (derivation, evaluation),
+  FOREIGN KEY (evaluation) REFERENCES Evaluations (id)
+);
+
 CREATE TABLE Builds (
   id              INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
   derivation      TEXT NOT NULL,
-- 
cgit v1.2.3

