-
Notifications
You must be signed in to change notification settings - Fork 1
/
hrms.sql
382 lines (305 loc) · 9.91 KB
/
hrms.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
-- This script was generated by a beta version of the ERD tool in pgAdmin 4.
-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.
BEGIN;
CREATE TABLE public.candidate_users
(
id integer NOT NULL,
first_name character varying(50) NOT NULL,
last_name character varying(50) NOT NULL,
identity_number character varying(11) NOT NULL,
date_of_birth date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.candidate_users_verify
(
id integer NOT NULL,
candidate_id integer NOT NULL,
status boolean,
PRIMARY KEY (id)
);
CREATE TABLE public.cities
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
city_name character varying(25) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.edu_graduates
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
description character varying NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employer_user_staff_verify
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
employer_id integer NOT NULL,
confirm_staff integer,
confirm_date date,
is_confirmed boolean,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employer_user_staff_verify_account_update
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
employer_id integer,
confirm_staff integer,
confirm_date date,
is_confirmed boolean NOT NULL,
created_date date NOT NULL,
temp_account_information jsonb NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employer_users
(
id integer NOT NULL,
company_name character varying(100) NOT NULL,
web_address character varying(50) NOT NULL,
phone_number character varying(17) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employer_users_verify
(
id integer NOT NULL,
employer_id integer NOT NULL,
status boolean,
PRIMARY KEY (id)
);
CREATE TABLE public.favorite_job_adverts
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
candidate_user_id integer NOT NULL,
job_advert_id integer NOT NULL,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.job_advert_staff_verify
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
job_advert_id integer NOT NULL,
confirm_staff_id integer,
confirm_date date,
is_confirmed boolean,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.job_adverts
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
employer_id integer NOT NULL,
position_id integer NOT NULL,
city_id integer NOT NULL,
advert_description character varying(250) NOT NULL,
min_salary integer,
max_salary integer,
open_position smallint NOT NULL,
deadline date,
created_date date NOT NULL,
is_active boolean NOT NULL,
working_place_id integer NOT NULL,
working_time_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.job_positions
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
"position" character varying(50) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.resume_edu
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
resume_id integer NOT NULL,
school_name character varying NOT NULL,
graduate_id integer NOT NULL,
school_department character varying NOT NULL,
started_date date NOT NULL,
ended_date date,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.resume_job_exp
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
resume_id integer NOT NULL,
company_name character varying NOT NULL,
job_position_id integer NOT NULL,
started_date date NOT NULL,
ended_date date,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.resume_langs
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
resume_id integer NOT NULL,
language character varying NOT NULL,
lang_level character(1) NOT NULL,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.resume_techs
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
resume_id integer NOT NULL,
description character varying NOT NULL,
created_date date NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.resumes
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
candidate_id integer NOT NULL,
github_link character varying,
linkedin_link character varying,
photo character varying,
description character varying,
created_date date NOT NULL,
is_active boolean,
updated_date date,
PRIMARY KEY (id)
);
CREATE TABLE public.staff_users
(
id integer NOT NULL,
first_name character varying(50) NOT NULL,
last_name character varying(50) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.users
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
email character varying(50) NOT NULL,
password character varying(32) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.verify_code
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
verify_code character varying(10) NOT NULL,
is_confirmed boolean,
created_date date NOT NULL,
confirmed_date date,
PRIMARY KEY (id)
);
CREATE TABLE public.working_place_types
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
working_place character varying(50) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.working_time_types
(
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
working_time character varying(50) NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE public.candidate_users
ADD FOREIGN KEY (id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.candidate_users_verify
ADD FOREIGN KEY (candidate_id)
REFERENCES public.candidate_users (id)
NOT VALID;
ALTER TABLE public.candidate_users_verify
ADD FOREIGN KEY (id)
REFERENCES public.verify_code (id)
NOT VALID;
ALTER TABLE public.employer_user_staff_verify
ADD FOREIGN KEY (employer_id)
REFERENCES public.employer_users (id)
NOT VALID;
ALTER TABLE public.employer_user_staff_verify
ADD FOREIGN KEY (confirm_staff)
REFERENCES public.staff_users (id)
NOT VALID;
ALTER TABLE public.employer_user_staff_verify_account_update
ADD FOREIGN KEY (confirm_staff)
REFERENCES public.staff_users (id)
NOT VALID;
ALTER TABLE public.employer_user_staff_verify_account_update
ADD FOREIGN KEY (employer_id)
REFERENCES public.employer_users (id)
NOT VALID;
ALTER TABLE public.employer_users
ADD FOREIGN KEY (id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.employer_users_verify
ADD FOREIGN KEY (employer_id)
REFERENCES public.employer_users (id)
NOT VALID;
ALTER TABLE public.employer_users_verify
ADD FOREIGN KEY (id)
REFERENCES public.verify_code (id)
NOT VALID;
ALTER TABLE public.favorite_job_adverts
ADD FOREIGN KEY (candidate_user_id)
REFERENCES public.candidate_users (id)
NOT VALID;
ALTER TABLE public.favorite_job_adverts
ADD FOREIGN KEY (job_advert_id)
REFERENCES public.job_adverts (id)
NOT VALID;
ALTER TABLE public.job_advert_staff_verify
ADD FOREIGN KEY (confirm_staff_id)
REFERENCES public.staff_users (id)
NOT VALID;
ALTER TABLE public.job_advert_staff_verify
ADD FOREIGN KEY (job_advert_id)
REFERENCES public.job_adverts (id)
NOT VALID;
ALTER TABLE public.job_adverts
ADD FOREIGN KEY (employer_id)
REFERENCES public.employer_users (id)
NOT VALID;
ALTER TABLE public.job_adverts
ADD FOREIGN KEY (city_id)
REFERENCES public.cities (id)
NOT VALID;
ALTER TABLE public.job_adverts
ADD FOREIGN KEY (position_id)
REFERENCES public.job_positions (id)
NOT VALID;
ALTER TABLE public.job_adverts
ADD FOREIGN KEY (working_place_id)
REFERENCES public.working_place_types (id)
NOT VALID;
ALTER TABLE public.job_adverts
ADD FOREIGN KEY (working_time_id)
REFERENCES public.working_time_types (id)
NOT VALID;
ALTER TABLE public.resume_edu
ADD FOREIGN KEY (graduate_id)
REFERENCES public.edu_graduates (id)
NOT VALID;
ALTER TABLE public.resume_edu
ADD FOREIGN KEY (resume_id)
REFERENCES public.resumes (id)
NOT VALID;
ALTER TABLE public.resume_job_exp
ADD FOREIGN KEY (job_position_id)
REFERENCES public.job_positions (id)
NOT VALID;
ALTER TABLE public.resume_job_exp
ADD FOREIGN KEY (resume_id)
REFERENCES public.resumes (id)
NOT VALID;
ALTER TABLE public.resume_langs
ADD FOREIGN KEY (resume_id)
REFERENCES public.resumes (id)
NOT VALID;
ALTER TABLE public.resume_techs
ADD FOREIGN KEY (resume_id)
REFERENCES public.resumes (id)
NOT VALID;
ALTER TABLE public.resumes
ADD FOREIGN KEY (candidate_id)
REFERENCES public.candidate_users (id)
NOT VALID;
ALTER TABLE public.staff_users
ADD FOREIGN KEY (id)
REFERENCES public.users (id)
NOT VALID;
END;