This repository has been archived by the owner on Jun 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.sql
194 lines (180 loc) · 4.04 KB
/
init.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
create table address
(
id serial not null
constraint address_pk
primary key,
hascoordinates boolean default false not null,
latitude numeric,
longitude numeric,
is_deleted boolean default false not null,
street_line_1 text,
street_line_2 text,
street_line_3 text,
street_line_4 text,
county text,
city text,
state text,
postal_code text,
country text not null
);
create unique index address_id_uindex
on address (id);
create table offer
(
id serial not null
constraint offer_pkey
primary key,
name text not null,
mail text not null,
phone text,
organisation text not null,
ispublic boolean default false not null,
address_id integer
constraint provider_address_id_fk
references address
on update cascade on delete cascade,
token text not null,
timestamp timestamp not null,
region text not null
);
create table consumable
(
id serial not null
constraint consumables_pk
primary key,
category text not null,
name text not null,
manufacturer text,
ordernumber text,
amount integer default 0 not null,
offer_id integer not null
constraint consumable_offer_id_fk
references offer
on update cascade on delete cascade,
unit text,
annotation text,
is_deleted boolean default false not null
);
create unique index consumables_id_uindex
on consumable (id);
create table device
(
category text not null,
name text not null,
id serial not null
constraint device_pk
primary key,
manufacturer text,
ordernumber text,
amount integer default 0 not null,
offer_id integer not null
constraint device_offer_id_fk
references offer
on update cascade on delete cascade,
annotation text,
is_deleted boolean default false not null
);
create unique index device_id_uindex
on device (id);
create table personal
(
id serial not null
constraint manpower_pk
primary key,
qualification text not null,
institution text not null,
researchgroup text,
area text not null,
experience_rt_pcr boolean default false not null,
annotation text,
offer_id integer
constraint personal_offer_id_fk
references offer
on update cascade on delete cascade,
is_deleted boolean default false not null
);
create unique index manpower_id_uindex
on personal (id);
create table region_subscription
(
id serial not null
constraint region_subscription_pk
primary key,
email text not null,
subscription_date timestamp default now() not null,
active boolean default true not null,
name text not null,
institution text not null,
postal_code text not null,
latitude numeric not null,
longitude numeric not null,
region text not null
);
create table change
(
id serial not null
constraint change_pk
primary key,
element_type text not null,
element_id integer not null,
change_type text not null,
timestamp timestamp not null,
reason text,
diff_amount integer default 0 not null,
element_category text,
element_name text,
region text not null
);
create table demand
(
id serial not null
constraint demand_pk
primary key,
institution text,
name text,
mail text not null,
phone text,
address_id integer
constraint demand_address_id_fk
references address,
annotation text,
token text not null,
created_at_timestamp timestamp not null
);
create index demand_token_index
on demand (token);
create table demand_device
(
id serial not null
constraint demand_device_pk
primary key,
demand_id integer not null
constraint demand_device_demand_id_fk
references demand
on update cascade on delete cascade,
category text not null,
name text,
manufacturer text,
amount integer not null,
annotation text,
created_at_timestamp timestamp not null,
is_deleted boolean not null
);
create table demand_consumable
(
id serial not null
constraint demand_consumable_pk
primary key,
demand_id integer not null
constraint demand_consumable_demand_id_fk
references demand
on update cascade on delete cascade,
category text not null,
name text,
manufacturer text,
amount integer not null,
unit text not null,
annotation text,
created_at_timestamp timestamp not null,
is_deleted boolean not null
);