-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.sql
434 lines (393 loc) · 14.8 KB
/
schema.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
create sequence if not exists flavour_id_seq;
create sequence if not exists flavour_limit_id_seq;
create sequence if not exists image_id_seq;
create sequence if not exists instance_authentication_token_id_seq;
create sequence if not exists instance_command_id_seq;
create sequence if not exists instance_id_seq;
create sequence if not exists instance_member_id_seq;
create sequence if not exists instance_session_id_seq;
create sequence if not exists protocol_id_seq;
create sequence if not exists role_id_seq;
create sequence if not exists instance_attribute_id_seq;
create table if not exists configuration
(
id bigserial not null
constraint configuration_pkey
primary key,
key varchar(256) not null,
value varchar(8192) not null
);
create table if not exists employer
(
id bigint not null
constraint employer_pkey
primary key,
country_code varchar(10),
name varchar(200),
town varchar(100)
);
create table if not exists flavour
(
id bigint default nextval('flavour_id_seq'::regclass) not null
constraint flavour_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
compute_id varchar(250) not null,
cpu real not null,
deleted boolean not null,
memory integer not null,
name varchar(250) not null,
description varchar(2500)
);
create table if not exists flavour_limit
(
id bigint default nextval('flavour_limit_id_seq'::regclass) not null
constraint flavour_limit_pkey
primary key,
object_id bigint not null,
object_type varchar(255) not null,
flavour_id bigint not null
constraint fk_flavour_id
references flavour
);
create table if not exists image
(
id bigint default nextval('image_id_seq'::regclass) not null
constraint image_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
boot_command text,
compute_id varchar(250) not null,
deleted boolean not null,
description varchar(2500),
icon varchar(100) not null,
name varchar(250) not null,
version varchar(100),
visible boolean not null,
autologin varchar(255)
);
create table if not exists instrument
(
id bigint not null
constraint instrument_pkey
primary key,
name varchar(250) not null
);
create table if not exists plan
(
id bigserial not null
constraint plan_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
preset boolean not null,
flavour_id bigint
constraint fk_flavour_id
references flavour,
image_id bigint
constraint fk_image_id
references image
);
create table if not exists instance
(
id bigint default nextval('instance_id_seq'::regclass) not null
constraint instance_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
comments varchar(2500),
compute_id varchar(250),
delete_requested boolean not null,
ip_address varchar(255),
last_interaction_at timestamp,
last_seen_at timestamp,
name varchar(250) not null,
screen_height integer not null,
screen_width integer not null,
state varchar(50) not null,
termination_date timestamp,
username varchar(100),
plan_id bigint
constraint fk_plan_id
references plan,
deleted_at timestamp,
keyboard_layout varchar(100) default 'en-gb-qwerty'::character varying,
security_groups text,
home_directory varchar(250)
);
create table if not exists instance_expiration
(
id bigserial not null
constraint instance_expiration_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
expiration_date timestamp not null,
instance_id bigint not null
constraint uk_instance_expiration_instance_id
unique
constraint fk_instance_id
references instance
);
create table if not exists instance_session
(
id bigint default nextval('instance_session_id_seq'::regclass) not null
constraint instance_session_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
connection_id varchar(150) not null,
current boolean not null,
instance_id bigint not null
constraint fk_instance_id
references instance
);
create table if not exists instance_thumbnail
(
id bigserial not null
constraint instance_thumbnail_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
data text not null,
instance_id bigint not null
constraint uk_instance_thumbnail_instance_id
unique
constraint fk_instance_id
references instance
);
create table if not exists proposal
(
id bigint not null
constraint proposal_pkey
primary key,
identifier varchar(100) not null,
title varchar(2000),
public_at timestamp,
summary varchar(5000)
);
create table if not exists experiment
(
id varchar(32) not null
constraint experiment_pkey
primary key,
instrument_id bigint not null
constraint fk_instrument_id
references instrument,
proposal_id bigint not null
constraint fk_proposal_id
references proposal,
end_date timestamp,
start_date timestamp
);
create table if not exists instance_experiment
(
instance_id bigint not null
constraint fk_instance_id
references instance,
experiment_id varchar(32) not null
constraint fk_experiment_id
references experiment,
constraint instance_experiment_pkey
primary key (experiment_id, instance_id)
);
create table if not exists protocol
(
id bigint default nextval('protocol_id_seq'::regclass) not null
constraint protocol_pkey
primary key,
name varchar(100) not null,
port integer not null
);
create table if not exists image_protocol
(
image_id bigint not null
constraint fk_image_id
references image,
protocol_id bigint not null
constraint fk_protocol_id
references protocol
);
create table if not exists role
(
id bigint default nextval('role_id_seq'::regclass) not null
constraint role_pkey
primary key,
description varchar(250),
name varchar(100) not null
constraint uk_role_name
unique
);
create table if not exists security_group
(
id bigserial not null
constraint security_group_pkey
primary key,
name varchar(250) not null
);
create table if not exists security_group_filter
(
id bigserial not null
constraint security_group_filter_pkey
primary key,
object_id bigint not null,
object_type varchar(255) not null,
security_group_id bigint not null
constraint fk_security_group_id
references security_group
);
create table if not exists system_notification
(
id bigserial not null
constraint system_notification_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
level varchar(50) not null,
message varchar(4096) not null
);
create table if not exists users
(
id varchar(250) not null
constraint users_pkey
primary key,
email varchar(100),
first_name varchar(100),
instance_quota integer not null,
last_name varchar(100) not null,
last_seen_at timestamp,
affiliation_id bigint
constraint fk_employer_id
references employer,
activated_at timestamp,
activated timestamp
);
create table if not exists experiment_user
(
experiment_id varchar(32) not null
constraint fk_experiment_id
references experiment,
user_id varchar(250) not null
constraint fk_users_id
references users,
constraint experiment_user_pkey
primary key (experiment_id, user_id)
);
create table if not exists instance_authentication_token
(
id bigint default nextval('instance_authentication_token_id_seq'::regclass) not null
constraint instance_authentication_token_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
token varchar(250) not null,
instance_id bigint not null
constraint fk_instance_id
references instance,
user_id varchar(250) not null
constraint fk_users_id
references users
);
create table if not exists instance_command
(
id bigint default nextval('instance_command_id_seq'::regclass) not null
constraint instance_command_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
action_type varchar(50) not null,
message varchar(255),
state varchar(50) not null,
instance_id bigint not null
constraint fk_instance_id
references instance,
user_id varchar(250)
constraint fk_users_id
references users
);
create table if not exists instance_jupyter_session
(
id bigserial not null
constraint instance_jupyter_session_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
active boolean not null,
kernel_id varchar(150) not null,
session_id varchar(150) not null,
instance_id bigint not null
constraint fk_instance_id
references instance,
user_id varchar(250) not null
constraint fk_users_id
references users
);
create table if not exists instance_member
(
id bigint default nextval('instance_member_id_seq'::regclass) not null
constraint instance_member_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
role varchar(255) not null,
user_id varchar(250) not null
constraint fk_users_id
references users,
instance_id bigint not null
constraint fk_instance_id
references instance
);
create table if not exists instance_session_member
(
id bigserial not null
constraint instance_session_member_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
active boolean not null,
last_interaction_at timestamp,
last_seen_at timestamp,
role varchar(150) not null,
session_id varchar(150) not null,
instance_session_id bigint not null
constraint fk_instance_session_id
references instance_session,
user_id varchar(250) not null
constraint fk_users_id
references users
);
create table if not exists instrument_scientist
(
instrument_id bigint not null
constraint fk_instrument_id
references instrument,
user_id varchar(250) not null
constraint fk_users_id
references users,
constraint instrument_responsible_pkey
primary key (instrument_id, user_id)
);
create table if not exists user_role
(
user_id varchar(250) not null
constraint fk_users_id
references users,
role_id bigint not null
constraint fk_role_id
references role
);
create table if not exists instance_attribute
(
id bigint default nextval('instance_attribute_id_seq'::regclass) not null
constraint instance_attribute_pkey
primary key,
created_at timestamp not null,
updated_at timestamp not null,
name varchar(255) not null,
value varchar(255) not null,
instance_id bigint not null
constraint fk_instance_id
references instance
);