summaryrefslogtreecommitdiff
path: root/tsp/results-schema.sql
blob: c47fb9aebb86ad0c055fdb7370f676624276a19c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
CREATE TABLE IF NOT EXISTS device (
    did INTEGER PRIMARY KEY,
    dname TEXT NOT NULL UNIQUE
);

CREATE TABLE IF NOT EXISTS result (
    rid INTEGER PRIMARY KEY,
    rname TEXT NOT NULL UNIQUE
);

CREATE TABLE IF NOT EXISTS test (
    tid INTEGER PRIMARY KEY AUTOINCREMENT,
    tnumber TEXT, tdate TEXT,
    tbuildnr INTEGER,
    trid INTEGER REFERENCES result (rid),
    tdid INTEGER REFERENCES device (did),
    UNIQUE (tnumber, tdid) ON CONFLICT REPLACE
);

CREATE VIEW IF NOT EXISTS currentstatus AS
    SELECT
        test.tnumber AS "SR",
        test.tdate AS "Date",
        test.tbuildnr AS "Build nr",
        device.dname AS "Device",
        result.rname AS "Status"
    FROM test
    INNER JOIN device ON test.tdid = device.did
    INNER JOIN result ON result.rid = test.trid
    ORDER BY SR DESC
;

CREATE VIEW IF NOT EXISTS currentstatus3 AS
    SELECT
        test.tnumber AS "SR",
        test.tdate AS "Date",
        test.tbuildnr AS "Build nr",
        device.dname AS "Device",
        result.rname AS "Status"
    FROM test
    INNER JOIN device ON test.tdid = device.did
    INNER JOIN result ON result.rid = test.trid
    WHERE SR LIKE "%3.0-common%"
    ORDER BY SR DESC
;

CREATE VIEW IF NOT EXISTS currentstatus4 AS
    SELECT
        test.tnumber AS "SR",
        test.tdate AS "Date",
        test.tbuildnr AS "Build nr",
        device.dname AS "Device",
        result.rname AS "Status"
    FROM test
    INNER JOIN device ON test.tdid = device.did
    INNER JOIN result ON result.rid = test.trid
    WHERE SR LIKE "%4.0-unified%"
    ORDER BY SR DESC
;