forked from SamP20/hackspace-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsample_dataset.sql
More file actions
562 lines (399 loc) · 14.5 KB
/
sample_dataset.sql
File metadata and controls
562 lines (399 loc) · 14.5 KB
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.2
-- Dumped by pg_dump version 16.2
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: discourse_invite; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.discourse_invite AS ENUM (
'no',
'invited',
'emailed',
'accepted',
'alumni'
);
ALTER TYPE public.discourse_invite OWNER TO postgres;
--
-- Name: induction_state; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.induction_state AS ENUM (
'valid',
'expired',
'banned'
);
ALTER TYPE public.induction_state OWNER TO postgres;
--
-- Name: legacy_machine_auth; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.legacy_machine_auth AS ENUM (
'none',
'password',
'padlock'
);
ALTER TYPE public.legacy_machine_auth OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: card; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.card (
id integer NOT NULL,
card_serial bigint,
number_on_front integer,
member_id integer,
lost boolean DEFAULT false NOT NULL,
unverified_serial bigint,
door_disabled boolean DEFAULT false NOT NULL
);
ALTER TABLE public.card OWNER TO postgres;
--
-- Name: card_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.card ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.card_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: induction; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.induction (
id integer NOT NULL,
member_id integer NOT NULL,
machine_id integer NOT NULL,
state public.induction_state NOT NULL,
inducted_by integer,
inducted_on date DEFAULT now(),
can_induct boolean DEFAULT false NOT NULL
);
ALTER TABLE public.induction OWNER TO postgres;
--
-- Name: induction_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.induction ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.induction_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: label; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.label (
id integer NOT NULL,
member_id integer,
expiry date NOT NULL,
caption character varying(255) NOT NULL,
printed boolean DEFAULT false NOT NULL
);
ALTER TABLE public.label OWNER TO postgres;
--
-- Name: label_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.label ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.label_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: machine; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.machine (
id integer NOT NULL,
name character varying(255) NOT NULL,
legacy_auth public.legacy_machine_auth DEFAULT 'none'::public.legacy_machine_auth NOT NULL,
legacy_password character varying(255) DEFAULT ''::character varying NOT NULL,
hide_from_home boolean DEFAULT false NOT NULL
);
ALTER TABLE public.machine OWNER TO postgres;
--
-- Name: machine_controller; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.machine_controller (
id integer NOT NULL,
machine_id integer,
requires_update boolean NOT NULL,
powered boolean DEFAULT false NOT NULL,
idle_timeout integer DEFAULT '-1'::integer NOT NULL,
idle_power_threshold integer DEFAULT 50 NOT NULL,
invert_logout_button boolean DEFAULT false NOT NULL,
hostname character varying(255) DEFAULT ''::character varying NOT NULL
);
ALTER TABLE public.machine_controller OWNER TO postgres;
--
-- Name: machine_controller_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.machine_controller ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.machine_controller_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: machine_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.machine ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.machine_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: member; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.member (
id integer NOT NULL,
first_name character varying(80) NOT NULL,
last_name character varying(80),
discourse_id integer,
discourse public.discourse_invite DEFAULT 'no'::public.discourse_invite NOT NULL,
newsletter boolean DEFAULT false NOT NULL,
email character varying(300),
alt_email character varying(300),
payment_ref character varying(200),
join_date date DEFAULT CURRENT_DATE NOT NULL,
end_date date,
end_reason character varying(500),
address1 character varying(200) DEFAULT ''::character varying NOT NULL,
address2 character varying(200) DEFAULT ''::character varying NOT NULL,
town_city character varying(200) DEFAULT ''::character varying NOT NULL,
county character varying(200) DEFAULT ''::character varying NOT NULL,
postcode character varying(20) DEFAULT ''::character varying NOT NULL,
payment_active boolean DEFAULT false NOT NULL,
notes text,
preferred_name character varying(160),
welcome_email_sent boolean DEFAULT false NOT NULL
);
ALTER TABLE public.member OWNER TO postgres;
--
-- Name: member_data_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.member ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.member_data_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: quiz; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.quiz (
id integer NOT NULL,
title character varying(200) NOT NULL,
description text,
questions text NOT NULL,
machine_id integer,
intro text DEFAULT ''::text NOT NULL,
hidden boolean DEFAULT false NOT NULL
);
ALTER TABLE public.quiz OWNER TO postgres;
--
-- Name: quiz_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
ALTER TABLE public.quiz ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
SEQUENCE NAME public.quiz_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Data for Name: card; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.card (id, card_serial, number_on_front, member_id, lost, unverified_serial, door_disabled) FROM stdin;
1 2864434397 111 \N f \N f
2 1122867 112 \N f \N f
3 2882351791 113 \N f \N f
4 0 100 7 f \N f
\.
--
-- Data for Name: induction; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.induction (id, member_id, machine_id, state, inducted_by, inducted_on, can_induct) FROM stdin;
1 7 2 valid \N 2024-04-25 f
\.
--
-- Data for Name: label; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.label (id, member_id, expiry, caption, printed) FROM stdin;
\.
--
-- Data for Name: machine; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.machine (id, name, legacy_auth, legacy_password, hide_from_home) FROM stdin;
1 Machine 1 none f
2 Machine 2 padlock 1234 f
3 Hidden Machine none t
\.
--
-- Data for Name: machine_controller; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.machine_controller (id, machine_id, requires_update, powered, idle_timeout, idle_power_threshold, invert_logout_button, hostname) FROM stdin;
1 1 f f -1 50 f aabbccdd
2 2 f f -1 50 f eeff0011
\.
--
-- Data for Name: member; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.member (id, first_name, last_name, discourse_id, discourse, newsletter, email, alt_email, payment_ref, join_date, end_date, end_reason, address1, address2, town_city, county, postcode, payment_active, notes, preferred_name, welcome_email_sent) FROM stdin;
1 Elliot Fisher \N no f elliotf@example.com \N \N 2024-04-25 \N \N f \N \N f
2 Donte Huang \N no f donte-huang@example.com \N \N 2024-04-25 \N \N f \N \N f
3 Leo Gates \N no f leog@example.com \N \N 2024-04-25 \N \N f \N \N f
4 Annika Arellano \N no f aarellano@example.com \N \N 2024-04-25 \N \N f \N \N f
5 Samson Roth \N no f sroth@example.com \N \N 2024-04-25 \N \N f \N \N f
6 Quinn Nobel \N no f quinnn@example.com \N \N 2024-04-25 \N \N f \N \N f
7 Example User \N no f example@example.com \N \N 2024-04-25 \N \N f \N \N f
\.
--
-- Data for Name: quiz; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.quiz (id, title, description, questions, machine_id, intro, hidden) FROM stdin;
1 Machine 1 Quiz Quiz for the first machine q1:\r\n type: pick_one\r\n correct_answer: a1\r\n label: Select the correct answer\r\n answers:\r\n a1: This is correct\r\n a2: This is wrong\r\n a3: This is also wrong\r\nq2:\r\n type: select_all\r\n correct_answers: ["a1", "a2"]\r\n label: Select the correct answers\r\n answers:\r\n a1: This is correct\r\n a2: This is also correct\r\n a3: This is wrong\r\nq3:\r\n type: yes_no\r\n correct_answer: yes\r\n label: You must tick this answer. 1 Welcome to the example quiz. Here's some different question types. f
\.
--
-- Name: card_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.card_id_seq', 4, true);
--
-- Name: induction_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.induction_id_seq', 1, true);
--
-- Name: label_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.label_id_seq', 1, false);
--
-- Name: machine_controller_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.machine_controller_id_seq', 2, true);
--
-- Name: machine_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.machine_id_seq', 3, true);
--
-- Name: member_data_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.member_data_id_seq', 7, true);
--
-- Name: quiz_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.quiz_id_seq', 1, true);
--
-- Name: card card_card_serial_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.card
ADD CONSTRAINT card_card_serial_key UNIQUE (card_serial);
--
-- Name: card card_number_on_front_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.card
ADD CONSTRAINT card_number_on_front_key UNIQUE (number_on_front);
--
-- Name: card card_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.card
ADD CONSTRAINT card_pkey PRIMARY KEY (id);
--
-- Name: induction induction_member_id_machine_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.induction
ADD CONSTRAINT induction_member_id_machine_id_key UNIQUE (member_id, machine_id);
--
-- Name: induction induction_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.induction
ADD CONSTRAINT induction_pkey PRIMARY KEY (id);
--
-- Name: label label_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.label
ADD CONSTRAINT label_pkey PRIMARY KEY (id);
--
-- Name: machine_controller machine_controller_hostname_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.machine_controller
ADD CONSTRAINT machine_controller_hostname_key UNIQUE (hostname);
--
-- Name: machine_controller machine_controller_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.machine_controller
ADD CONSTRAINT machine_controller_pkey PRIMARY KEY (id);
--
-- Name: machine machine_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.machine
ADD CONSTRAINT machine_pkey PRIMARY KEY (id);
--
-- Name: member member_data_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.member
ADD CONSTRAINT member_data_pkey PRIMARY KEY (id);
--
-- Name: quiz quiz_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.quiz
ADD CONSTRAINT quiz_pkey PRIMARY KEY (id);
--
-- Name: card card_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.card
ADD CONSTRAINT card_member_id_fkey FOREIGN KEY (member_id) REFERENCES public.member(id) NOT VALID;
--
-- Name: induction induction_inducted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.induction
ADD CONSTRAINT induction_inducted_by_fkey FOREIGN KEY (inducted_by) REFERENCES public.member(id) ON UPDATE CASCADE ON DELETE SET NULL NOT VALID;
--
-- Name: induction induction_machine_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.induction
ADD CONSTRAINT induction_machine_id_fkey FOREIGN KEY (machine_id) REFERENCES public.machine(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: induction induction_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.induction
ADD CONSTRAINT induction_member_id_fkey FOREIGN KEY (member_id) REFERENCES public.member(id) ON UPDATE RESTRICT ON DELETE RESTRICT NOT VALID;
--
-- Name: label label_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.label
ADD CONSTRAINT label_member_id_fkey FOREIGN KEY (member_id) REFERENCES public.member(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Name: machine_controller machine_controller_machine_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.machine_controller
ADD CONSTRAINT machine_controller_machine_id_fkey FOREIGN KEY (machine_id) REFERENCES public.machine(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Name: quiz quiz_machine_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.quiz
ADD CONSTRAINT quiz_machine_id_fkey FOREIGN KEY (machine_id) REFERENCES public.machine(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- PostgreSQL database dump complete
--