-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdataBaseSchema.sql
297 lines (197 loc) · 7.06 KB
/
dataBaseSchema.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
--
-- Guide: Insert this file inside a query window in PostgreSql. Exchange dev user at the bottom with the user you want to use for accesing the database
-- There will be a root login for the open certification trainer with username and passwort root
--
--
-- Don't remove: pgcrypto extensions needs to be loaded
--
CREATE EXTENSION IF NOT EXISTS pgcrypto;
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.1
-- Dumped by pg_dump version 10.1
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: open_certification_trainer; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA open_certification_trainer;
ALTER SCHEMA open_certification_trainer OWNER TO postgres;
SET search_path = open_certification_trainer, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: answer; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE answer (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
key character varying(255),
text text,
is_correct boolean,
question_id uuid
);
ALTER TABLE answer OWNER TO postgres;
--
-- Name: assessment_session; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE assessment_session (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
user_id uuid,
certification_id uuid,
session json,
in_progress boolean,
created_on timestamp without time zone DEFAULT timezone('utc'::text, now())
);
ALTER TABLE assessment_session OWNER TO postgres;
--
-- Name: certification; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE certification (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
name character varying(255),
unique_name character varying(255),
is_published boolean,
version character varying(255)
);
ALTER TABLE certification OWNER TO postgres;
--
-- Name: post; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE post (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
content text,
created_on timestamp without time zone DEFAULT timezone('utc'::text, now())
);
ALTER TABLE post OWNER TO postgres;
--
-- Name: question; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE question (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
key character varying(255) NOT NULL,
text text,
certification_id uuid,
"position" integer,
explanation text
);
ALTER TABLE question OWNER TO postgres;
--
-- Name: user; Type: TABLE; Schema: open_certification_trainer; Owner: postgres
--
CREATE TABLE "user" (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
user_name character varying(255),
email character varying(255),
is_admin boolean,
password_hash character(60),
first_name character varying(255),
last_name character varying(255)
);
ALTER TABLE "user" OWNER TO postgres;
--
-- Data for Name: user; Type: TABLE DATA; Schema: open_certification_trainer; Owner: postgres
--
COPY "user" (id, user_name, email, is_admin, password_hash, first_name, last_name) FROM stdin;
f39f13b4-b8c6-4013-ace6-087a45dbd23d root [email protected] t $2a$10$covQWp6GhzWOIik3T6oiveFVnIxTVG7X1c9ziHRM3jTiEFPT0cjd2 root root
\.
--
-- Name: answer answer_pkey; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY answer
ADD CONSTRAINT answer_pkey PRIMARY KEY (id);
--
-- Name: assessment_session assessment_session_pkey; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY assessment_session
ADD CONSTRAINT assessment_session_pkey PRIMARY KEY (id);
--
-- Name: certification id; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY certification
ADD CONSTRAINT id PRIMARY KEY (id);
--
-- Name: post post_pkey; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY post
ADD CONSTRAINT post_pkey PRIMARY KEY (id);
--
-- Name: question question_key_certification_id_unique; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY question
ADD CONSTRAINT question_key_certification_id_unique UNIQUE (key, certification_id);
--
-- Name: question question_pkey; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY question
ADD CONSTRAINT question_pkey PRIMARY KEY (id);
--
-- Name: certification unique_name; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY certification
ADD CONSTRAINT unique_name UNIQUE (unique_name);
--
-- Name: user user_name; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_name UNIQUE (user_name);
--
-- Name: user user_pkey; Type: CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_pkey PRIMARY KEY (id);
--
-- Name: user_id_certification_id_unique; Type: INDEX; Schema: open_certification_trainer; Owner: postgres
--
CREATE UNIQUE INDEX user_id_certification_id_unique ON assessment_session USING btree (user_id, certification_id) WHERE in_progress;
--
-- Name: ux_user_case_insensitive_user_name; Type: INDEX; Schema: open_certification_trainer; Owner: postgres
--
CREATE UNIQUE INDEX ux_user_case_insensitive_user_name ON "user" USING btree (lower((user_name)::text));
--
-- Name: answer answer_question_id_fkey; Type: FK CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY answer
ADD CONSTRAINT answer_question_id_fkey FOREIGN KEY (question_id) REFERENCES question(id) ON DELETE CASCADE;
--
-- Name: question question_certification_id_fkey; Type: FK CONSTRAINT; Schema: open_certification_trainer; Owner: postgres
--
ALTER TABLE ONLY question
ADD CONSTRAINT question_certification_id_fkey FOREIGN KEY (certification_id) REFERENCES certification(id) ON DELETE CASCADE;
--
-- Name: open_certification_trainer; Type: ACL; Schema: -; Owner: postgres
--
GRANT ALL ON SCHEMA open_certification_trainer TO dev;
--
-- Name: answer; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE answer TO dev;
--
-- Name: assessment_session; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE assessment_session TO dev;
--
-- Name: certification; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE certification TO dev;
--
-- Name: post; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE post TO dev;
--
-- Name: question; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE question TO dev;
--
-- Name: user; Type: ACL; Schema: open_certification_trainer; Owner: postgres
--
GRANT ALL ON TABLE "user" TO dev;
--
-- PostgreSQL database dump complete
--