-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump.sql
224 lines (178 loc) · 4.75 KB
/
dump.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
create schema sky;
alter schema sky owner to postgres;
set schema 'sky';
create table "SpaceType"
(
"Id" serial not null
constraint spacetype_pk
primary key,
"Name" varchar not null,
"Description" text
);
alter table "SpaceType" owner to postgres;
create unique index spacetype_id_uindex
on "SpaceType" ("Id");
create table "Space"
(
"Id" serial not null
constraint space_pk
primary key,
"Name" varchar not null,
"Description" text,
"Type_fk" integer not null
constraint space_spacetype_id_fk
references "SpaceType"
);
alter table "Space" owner to postgres;
create unique index space_id_uindex
on "Space" ("Id");
create table "AccidentType"
(
"Id" serial not null
constraint accidenttype_pk
primary key,
"Name" varchar not null,
"Description" text
);
alter table "AccidentType" owner to postgres;
create unique index accidenttype_id_uindex
on "AccidentType" ("Id");
create table "Units"
(
"Id" serial not null
constraint units_pk
primary key,
"Name" varchar not null,
"Description" text
);
alter table "Units" owner to postgres;
create unique index units_id_uindex
on "Units" ("Id");
create table "Objects"
(
"Id" serial not null
constraint objects_pk
primary key,
"Name" varchar not null,
"Description" text,
"Space_fk" integer
constraint objects_space_id_fk
references "Space",
"State_fk" integer
);
alter table "Objects" owner to postgres;
create table "States"
(
"Id" serial not null
constraint states_pk
primary key,
"Name" varchar not null,
"Description" integer,
"Value" double precision,
"TimeChanged" timestamp,
"Objects_fk" integer
constraint states_objects_id_fk
references "Objects"
);
alter table "States" owner to postgres;
create unique index states_id_uindex
on "States" ("Id");
create table "Variable"
(
"Id" serial not null
constraint variable_pk
primary key,
"Name" varchar not null,
"Value" real not null,
"Description" text,
"Unit_fk" integer
constraint variable_units_id_fk
references "Units",
"Objects_fk" integer
constraint variable_objects_id_fk
references "Objects"
);
alter table "Variable" owner to postgres;
create unique index variable_id_uindex
on "Variable" ("Id");
create unique index objects_id_uindex
on "Objects" ("Id");
create table "Object_Has_Object"
(
"Id" serial not null
constraint object_has_object_pk
primary key,
"Parent" integer not null
constraint "Parent_id_fk"
references "Objects",
"Child" integer not null
constraint "Child_id_fk"
references "Objects"
);
alter table "Object_Has_Object" owner to postgres;
create unique index object_has_object_id_uindex
on "Object_Has_Object" ("Id");
create table "Accident"
(
"Id" serial not null,
"Objects_fk" integer
constraint accident_objects_id_fk
references "Objects",
"Data" integer,
"Timestamp" timestamp not null,
"AccidentType_fk" integer
constraint accident_accidenttype_id_fk
references "AccidentType"
);
alter table "Accident" owner to postgres;
create unique index accident_id_uindex
on "Accident" ("Id");
alter table "Accident"
add constraint accident_pk
primary key ("Id");
create table "VariableValue"
(
"Id" serial not null
constraint variablevalue_pk
primary key,
"Variable_fk" integer
constraint variablevalue_variable_id_fk
references "Variable",
"Value" real not null,
"Timestamp" timestamp not null
);
alter table "VariableValue" owner to postgres;
create unique index variablevalue_id_uindex
on "VariableValue" ("Id");
create table "gateway_pass_event"
(
"id" serial not null,
"ext_id" integer,
"is_passed" boolean,
"gateway_id" integer,
"is_in_direction" boolean,
"s_persone_id" varchar,
"s_card_id" varchar,
"timestamp" integer not null
);
alter table "gateway_pass_event" owner to postgres;
create unique index gateway_pass_event_id_uindex
on "gateway_pass_event" ("id");
alter table "gateway_pass_event"
add constraint gateway_pass_event_pk
primary key ("id");
create table "switch_event"
(
"id" serial not null,
"s_device_id" varchar,
"line_id" integer,
"is_turned_on" boolean,
"is_succeed" boolean,
"timestamp" integer not null
);
alter table "switch_event" owner to postgres;
create unique index switch_event_id_uindex
on "switch_event" ("id");
alter table "switch_event"
add constraint switch_event_pk
primary key ("id");