From 1ccc68defdb1f67f39dc836ee6659a89135c038c Mon Sep 17 00:00:00 2001
From: Georgios Andreadis <g.andreadis@student.tudelft.nl>
Date: Mon, 12 Mar 2018 07:33:59 +0100
Subject: feat: Add task metrics to DB schema

---
 database/schema.sql | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'database/schema.sql')

diff --git a/database/schema.sql b/database/schema.sql
index 9e356b4a..3b751c30 100644
--- a/database/schema.sql
+++ b/database/schema.sql
@@ -233,6 +233,7 @@ CREATE TABLE task_states (
 );
 
 -- The measurements of a single stage
+DROP TABLE IF EXISTS stage_measurements;
 CREATE TABLE stage_measurements (
   id            INTEGER PRIMARY KEY     NOT NULL AUTO_INCREMENT,
   experiment_id INTEGER                 NOT NULL,
@@ -246,6 +247,24 @@ CREATE TABLE stage_measurements (
     ON UPDATE CASCADE
 );
 
+-- Metrics of a single task
+DROP TABLE IF EXISTS task_metrics;
+CREATE TABLE task_metrics (
+  id            INTEGER PRIMARY KEY     NOT NULL AUTO_INCREMENT,
+  experiment_id INTEGER                 NOT NULL,
+  task_id       INTEGER                 NOT NULL,
+  waiting       INTEGER                 NOT NULL CHECK (waiting >= 0),
+  execution     INTEGER                 NOT NULL CHECK (execution >= 0),
+  turnaround    INTEGER                 NOT NULL CHECK (turnaround >= 0),
+
+  FOREIGN KEY (experiment_id) REFERENCES experiments (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE,
+  FOREIGN KEY (task_id) REFERENCES tasks (id)
+    ON DELETE CASCADE
+    ON UPDATE CASCADE
+);
+
 -- A machine state
 DROP TABLE IF EXISTS machine_states;
 CREATE TABLE machine_states (
-- 
cgit v1.2.3

