forked from scalableminds/webknossos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path089-voxelytics.sql
138 lines (123 loc) · 5.27 KB
/
089-voxelytics.sql
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
START TRANSACTION;
CREATE TYPE webknossos.VOXELYTICS_RUN_STATE AS ENUM ('PENDING', 'SKIPPED', 'RUNNING', 'COMPLETE', 'FAILED', 'CANCELLED', 'STALE');
CREATE TABLE webknossos.voxelytics_artifacts (
_id CHAR(24) NOT NULL,
_task CHAR(24) NOT NULL,
name VARCHAR(512) NOT NULL,
path TEXT NOT NULL,
fileSize INT8 NOT NULL,
inodeCount INT8 NOT NULL,
version TEXT NOT NULL DEFAULT '0',
metadata JSONB,
PRIMARY KEY (_id),
UNIQUE (_task, name),
CONSTRAINT metadataIsJsonObject CHECK(jsonb_typeof(metadata) = 'object')
);
CREATE TABLE webknossos.voxelytics_runs (
_id CHAR(24) NOT NULL,
_organization CHAR(24) NOT NULL,
_user CHAR(24) NOT NULL,
name VARCHAR(2048) NOT NULL,
username TEXT NOT NULL,
hostname TEXT NOT NULL,
voxelyticsVersion TEXT NOT NULL,
workflow_hash VARCHAR(512) NOT NULL,
workflow_yamlContent TEXT,
workflow_config JSONB,
PRIMARY KEY (_id),
UNIQUE (_organization, name),
CONSTRAINT workflowConfigIsJsonObject CHECK(jsonb_typeof(workflow_config) = 'object')
);
CREATE TABLE webknossos.voxelytics_tasks (
_id CHAR(24) NOT NULL,
_run CHAR(24) NOT NULL,
name varCHAR(2048) NOT NULL,
task varCHAR(512) NOT NULL,
config JSONB NOT NULL,
PRIMARY KEY (_id),
UNIQUE (_run, name),
CONSTRAINT configIsJsonObject CHECK(jsonb_typeof(config) = 'object')
);
CREATE TABLE webknossos.voxelytics_chunks (
_id CHAR(24) NOT NULL,
_task CHAR(24) NOT NULL,
executionId VARCHAR(2048) NOT NULL,
chunkName VARCHAR(2048) NOT NULL,
PRIMARY KEY (_id),
UNIQUE (_task, executionId, chunkName)
);
CREATE TABLE webknossos.voxelytics_workflows (
_organization CHAR(24) NOT NULL,
hash VARCHAR(512) NOT NULL,
name TEXT NOT NULL,
PRIMARY KEY (_organization, hash)
);
CREATE TABLE webknossos.voxelytics_runStateChangeEvents (
_run CHAR(24) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
state webknossos.VOXELYTICS_RUN_STATE NOT NULL,
PRIMARY KEY (_run, timestamp)
);
CREATE TABLE webknossos.voxelytics_runHeartbeatEvents (
_run CHAR(24) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
PRIMARY KEY (_run)
);
CREATE TABLE webknossos.voxelytics_taskStateChangeEvents (
_task CHAR(24) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
state webknossos.VOXELYTICS_RUN_STATE NOT NULL,
PRIMARY KEY (_task, timestamp)
);
CREATE TABLE webknossos.voxelytics_chunkStateChangeEvents (
_chunk CHAR(24) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
state webknossos.VOXELYTICS_RUN_STATE NOT NULL,
PRIMARY KEY (_chunk, timestamp)
);
CREATE TABLE webknossos.voxelytics_chunkProfilingEvents (
_chunk CHAR(24) NOT NULL,
hostname TEXT NOT NULL,
pid INT8 NOT NULL,
memory FLOAT NOT NULL,
cpuUser FLOAT NOT NULL,
cpuSystem FLOAT NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
PRIMARY KEY (_chunk, timestamp)
);
CREATE TABLE webknossos.voxelytics_artifactFileChecksumEvents (
_artifact CHAR(24) NOT NULL,
path TEXT NOT NULL,
resolvedPath TEXT NOT NULL,
checksumMethod VARCHAR(512) NOT NULL,
checksum VARCHAR(512) NOT NULL,
fileSize INT8 NOT NULL,
lastModified TIMESTAMPTZ NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
PRIMARY KEY (_artifact, path, timestamp)
);
ALTER TABLE webknossos.voxelytics_artifacts
ADD FOREIGN KEY (_task) REFERENCES webknossos.voxelytics_tasks(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_runs
ADD FOREIGN KEY (_organization) REFERENCES webknossos.organizations(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE,
ADD FOREIGN KEY (_organization, workflow_hash) REFERENCES webknossos.voxelytics_workflows(_organization, hash) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_tasks
ADD FOREIGN KEY (_run) REFERENCES webknossos.voxelytics_runs(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_chunks
ADD FOREIGN KEY (_task) REFERENCES webknossos.voxelytics_tasks(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_workflows
ADD FOREIGN KEY (_organization) REFERENCES webknossos.organizations(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_runStateChangeEvents
ADD FOREIGN KEY (_run) REFERENCES webknossos.voxelytics_runs(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_runHeartbeatEvents
ADD FOREIGN KEY (_run) REFERENCES webknossos.voxelytics_runs(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_taskStateChangeEvents
ADD FOREIGN KEY (_task) REFERENCES webknossos.voxelytics_tasks(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_chunkStateChangeEvents
ADD FOREIGN KEY (_chunk) REFERENCES webknossos.voxelytics_chunks(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_chunkProfilingEvents
ADD FOREIGN KEY (_chunk) REFERENCES webknossos.voxelytics_chunks(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
ALTER TABLE webknossos.voxelytics_artifactFileChecksumEvents
ADD FOREIGN KEY (_artifact) REFERENCES webknossos.voxelytics_artifacts(_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
UPDATE webknossos.releaseInformation SET schemaVersion = 89;
COMMIT TRANSACTION;