aboutsummaryrefslogtreecommitdiff
path: root/wa/commands/postgres_schemas/postgres_schema.sql
blob: 7510c77857d51966894d4b4ace5513cee7c28df8 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
--!VERSION!1.2!ENDVERSION!
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "lo";

-- In future, it may be useful to implement rules on which Parameter oid fields can be none depeendent on the value in the type column;

DROP TABLE IF EXISTS DatabaseMeta;
DROP TABLE IF EXISTS Parameters;
DROP TABLE IF EXISTS Classifiers;
DROP TABLE IF EXISTS LargeObjects;
DROP TABLE IF EXISTS Artifacts;
DROP TABLE IF EXISTS Metrics;
DROP TABLE IF EXISTS Augmentations;
DROP TABLE IF EXISTS Jobs_Augs;
DROP TABLE IF EXISTS ResourceGetters;
DROP TABLE IF EXISTS Resource_Getters;
DROP TABLE IF EXISTS Events;
DROP TABLE IF EXISTS Targets;
DROP TABLE IF EXISTS Jobs;
DROP TABLE IF EXISTS Runs;

DROP TYPE IF EXISTS status_enum;
DROP TYPE IF EXISTS param_enum;

CREATE TYPE status_enum AS ENUM ('UNKNOWN(0)','NEW(1)','PENDING(2)','STARTED(3)','CONNECTED(4)', 'INITIALIZED(5)', 'RUNNING(6)', 'OK(7)', 'PARTIAL(8)', 'FAILED(9)', 'ABORTED(10)', 'SKIPPED(11)');

CREATE TYPE param_enum AS ENUM ('workload', 'resource_getter', 'augmentation', 'device', 'runtime', 'boot');

-- In future, it might be useful to create an ENUM type for the artifact kind, or simply a generic enum type;

CREATE TABLE DatabaseMeta (
    oid uuid NOT NULL,
    schema_major int,
    schema_minor int,
    PRIMARY KEY (oid)
);

CREATE TABLE Runs (
    oid uuid NOT NULL,
    event_summary text,
    basepath text,
    status status_enum,
    timestamp timestamp,
    run_name text,
    project text,
    project_stage text,
    retry_on_status status_enum[],
    max_retries int,
    bail_on_init_failure boolean,
    allow_phone_home boolean,
    run_uuid uuid,
    start_time timestamp,
    end_time timestamp,
    duration float,
    metadata jsonb,
    _pod_version int,
    _pod_serialization_version int,
    state jsonb,
    PRIMARY KEY (oid)
);

CREATE TABLE Jobs (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    status status_enum,
    retry int,
    label text,
    job_id text,
    iterations int,
    workload_name text,
    metadata jsonb,
    _pod_version int,
    _pod_serialization_version int,
    PRIMARY KEY (oid)
);

CREATE TABLE Targets (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    target text,
    cpus text[],
    os text,
    os_version jsonb,
    hostid int,
    hostname text,
    abi text,
    is_rooted boolean,
    kernel_version text,
    kernel_release text,
    kernel_sha1 text,
    kernel_config text[],
    sched_features text[],
    page_size_kb int,
    screen_resolution int[],
    prop json,
    android_id text,
    _pod_version int,
    _pod_serialization_version int,
    PRIMARY KEY (oid)
);

CREATE TABLE Events (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    job_oid uuid references Jobs(oid),
    timestamp timestamp,
    message text,
    _pod_version int,
    _pod_serialization_version int,
    PRIMARY KEY (oid)
);

CREATE TABLE Resource_Getters (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    name text,
    PRIMARY KEY (oid)
);

CREATE TABLE Augmentations (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    name text,
    PRIMARY KEY (oid)
);

CREATE TABLE Jobs_Augs (
    oid uuid NOT NULL,
    job_oid uuid NOT NULL references Jobs(oid),
    augmentation_oid uuid NOT NULL references Augmentations(oid),
    PRIMARY KEY (oid)
);

CREATE TABLE Metrics (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    job_oid uuid references Jobs(oid),
    name text,
    value double precision,
    units text,
    lower_is_better boolean,
    _pod_version int,
    _pod_serialization_version int,
    PRIMARY KEY (oid)
);

CREATE TABLE LargeObjects (
    oid uuid NOT NULL,
    lo_oid lo NOT NULL,
    PRIMARY KEY (oid)
);

-- Trigger that allows you to manage large objects from the LO table directly;
CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON LargeObjects
    FOR EACH ROW EXECUTE PROCEDURE lo_manage(lo_oid);

CREATE TABLE Artifacts (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    job_oid uuid references Jobs(oid),
    name text,
    large_object_uuid uuid NOT NULL references LargeObjects(oid),
    description text,
    kind text,
    _pod_version int,
    _pod_serialization_version int,
    PRIMARY KEY (oid)
);

CREATE TABLE Classifiers (
    oid uuid NOT NULL,
    artifact_oid uuid references Artifacts(oid),
    metric_oid uuid references Metrics(oid),
    job_oid uuid references Jobs(oid),
    run_oid uuid references Runs(oid),
    key text,
    value text,
    PRIMARY KEY (oid)
);

CREATE TABLE Parameters (
    oid uuid NOT NULL,
    run_oid uuid NOT NULL references Runs(oid),
    job_oid uuid references Jobs(oid),
    augmentation_oid uuid references Augmentations(oid),
    resource_getter_oid uuid references Resource_Getters(oid),
    name text,
    value text,
    value_type text,
    type param_enum,
    PRIMARY KEY (oid)
);