-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabaseScript.txt
123 lines (99 loc) · 2.78 KB
/
databaseScript.txt
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
-- 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.admin_users
(
id integer NOT NULL,
first_name character varying(25) NOT NULL,
last_name character varying(25) NOT NULL,
user_type_id integer NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employees
(
id integer NOT NULL,
first_name character varying(25) NOT NULL,
last_name character varying(25) NOT NULL,
identity_number character varying(11) NOT NULL,
date_of_birth "char" NOT NULL,
user_type_id integer NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.employers
(
id integer NOT NULL,
company_name character varying(50) NOT NULL,
web_address character varying(50) NOT NULL,
phone_number character varying(12) NOT NULL,
user_type_id integer NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.job_titles
(
id integer NOT NULL,
title character varying(50) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.user_activations
(
id integer NOT NULL,
activation_code character varying(50) NOT NULL,
is_confirmed boolean NOT NULL,
confirmation_date date NOT NULL,
user_id integer NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.user_activations_by_admin_users
(
id integer NOT NULL,
confirmed_employee_id integer NOT NULL,
confirmation_date date NOT NULL,
is_confirmed boolean NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.user_types
(
id integer NOT NULL,
user_type character varying(30) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.users
(
id integer NOT NULL,
email character varying(50) NOT NULL,
password character varying(500),
password_again character varying(500) NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE public.admin_users
ADD FOREIGN KEY (user_id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.admin_users
ADD FOREIGN KEY (user_type_id)
REFERENCES public.user_types (id)
NOT VALID;
ALTER TABLE public.employees
ADD FOREIGN KEY (user_id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.employees
ADD FOREIGN KEY (user_type_id)
REFERENCES public.user_types (id)
NOT VALID;
ALTER TABLE public.employers
ADD FOREIGN KEY (user_id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.user_activations
ADD FOREIGN KEY (user_id)
REFERENCES public.users (id)
NOT VALID;
ALTER TABLE public.user_activations_by_admin_users
ADD FOREIGN KEY (confirmed_employee_id)
REFERENCES public.employees (id)
NOT VALID;
END;