-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
167 lines (140 loc) · 4.33 KB
/
init.sql
File metadata and controls
167 lines (140 loc) · 4.33 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
create table if not exists public.tools
(
code varchar(255) not null
primary key,
additional_info varchar(255),
description varchar(255),
icon varchar(255),
name varchar(255),
place_column varchar(255),
place_row varchar(255),
place_shelf varchar(255),
type varchar(255)
constraint tools_type_check
check ((type)::text = ANY
((ARRAY ['CUTTING'::character varying, 'MEASURE'::character varying, 'HELPERS'::character varying])::text[]))
);
TABLESPACE pg_default;
alter table tools
owner to bogdan;
create table if not exists public.workers
(
id bigint not null
primary key,
department varchar(255)
constraint workers_department_check
check ((department)::text = ANY
((ARRAY ['DEPARTMENT_19'::character varying, 'MAIN_STORAGE'::character varying, 'SHARPENING'::character varying, 'STORAGE_OF_DECOMMISSIONED_TOOLS'::character varying])::text[])),
first_name varchar(255),
join_date date,
last_name varchar(255),
login varchar(255),
patronymic varchar(255),
type varchar(255)
constraint workers_type_check
check ((type)::text = ANY
((ARRAY ['WORKER'::character varying, 'STORAGE_WORKER'::character varying])::text[]))
);
TABLESPACE pg_default;
alter table workers
owner to bogdan;
create table if not exists public.storage_records
(
id bigint generated by default as identity
primary key,
amount integer,
tool_code varchar(255)
constraint fkrwbvquho3lb9d452t569ddt5l
references tools,
worker_id bigint
constraint fk8vluiwjqqt7ilbsct9wuqgbej
references workers
);
TABLESPACE pg_default;
alter table storage_records
owner to bogdan;
create table if not exists public.tools_transactions
(
code varchar(255) not null
primary key,
name varchar(255)
);
TABLESPACE pg_default;
alter table tools_transactions
owner to bogdan;
create table if not exists public.workers_transaction
(
id bigint not null
primary key,
department varchar(255)
constraint workers_transaction_department_check
check ((department)::text = ANY
((ARRAY ['DEPARTMENT_19'::character varying, 'MAIN_STORAGE'::character varying, 'SHARPENING'::character varying, 'STORAGE_OF_DECOMMISSIONED_TOOLS'::character varying])::text[])),
first_name varchar(255),
last_name varchar(255)
);
TABLESPACE pg_default;
alter table workers_transaction
owner to bogdan;
create table if not exists public.transactions
(
id bigint generated by default as identity
primary key,
amount integer,
transaction_date date,
receiver_id bigint
constraint fkk162ocbhl9m2qu84rnf3kxqy2
references workers_transaction,
sender_id bigint
constraint fkoh2iep7bsbtvc6o7s63lqscki
references workers_transaction,
tool_code varchar(255)
constraint fkcm3mue2xukg8cma165l61ow9r
references tools_transactions
);
TABLESPACE pg_default;
alter table transactions
owner to bogdan;
create table if not exists public.jaws
(
id bigserial
primary key,
description varchar(255),
name varchar(255) not null,
operation_number varchar(255) not null,
place_column varchar(255),
place_row varchar(255),
place_shelf varchar(255)
);
TABLESPACE pg_default;
alter table jaws
owner to bogdan;
create table if not exists public.jaw_photos
(
id bigserial
primary key,
create_date timestamp(6),
file_name varchar(255),
url varchar(255),
jaws_id bigint
constraint fka3mwto64bn4jtupall1a44t6r
references jaws
);
TABLESPACE pg_default;
alter table jaw_photos
owner to bogdan;
create table if not exists public.users
(
id bigserial
primary key,
password varchar(255) not null,
role varchar(255) not null
constraint users_role_check
check ((role)::text = 'USER'::text),
username varchar(255) not null
constraint uk_r43af9ap4edm43mmtq01oddj6
unique
);
TABLESPACE pg_default;
alter table users
owner to bogdan;