sql-typechecker 0.0.7 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cli.js +133 -88
- package/out/cli.js.map +2 -2
- package/out/typeparsers.js +1 -1
- package/out/typeparsers.js.map +2 -2
- package/package.json +5 -5
- package/.envrc +0 -2
- package/esbuild.js +0 -12
- package/index.ts +0 -22
- package/sample/nested/sample2.sql +0 -26
- package/sample/out.ts +0 -70
- package/sample/sample1.sql +0 -20
- package/school/sql.sql +0 -1055
- package/school/test.ts +0 -27
- package/shell.nix +0 -16
- package/src/builtincasts.ts +0 -277
- package/src/builtinoperators.ts +0 -5144
- package/src/builtinunaryoperators.ts +0 -291
- package/src/cli.ts +0 -144
- package/src/codegen.ts +0 -384
- package/src/readme.md +0 -23
- package/src/typecheck.ts +0 -2143
- package/src/typeparsers.ts +0 -33
- package/template1.sql +0 -43
- package/test/test.ts +0 -1378
- package/tsconfig.json +0 -23
package/school/sql.sql
DELETED
|
@@ -1,1055 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|
3
|
-
|
|
4
|
-
CREATE SEQUENCE uw_AjaxUpload_handles;
|
|
5
|
-
|
|
6
|
-
CREATE TABLE uw_AjaxUpload_scratch(
|
|
7
|
-
uw_handle int8 NOT NULL,
|
|
8
|
-
uw_filename text,
|
|
9
|
-
uw_mimetype text NOT NULL,
|
|
10
|
-
uw_content bytea NOT NULL,
|
|
11
|
-
uw_created timestamp NOT NULL,
|
|
12
|
-
CONSTRAINT uw_AjaxUpload_scratch_pkey PRIMARY KEY (uw_handle));
|
|
13
|
-
|
|
14
|
-
CREATE TABLE uw_Teacherscanplan_tab(
|
|
15
|
-
uw_version int8 NOT NULL,
|
|
16
|
-
uw_value bool NOT NULL,
|
|
17
|
-
uw_islastversion bool NOT NULL,
|
|
18
|
-
uw_stamp timestamp NOT NULL);
|
|
19
|
-
|
|
20
|
-
CREATE SEQUENCE uw_Monitoring_seq;
|
|
21
|
-
|
|
22
|
-
CREATE TABLE uw_Monitoring_errors(
|
|
23
|
-
uw_id int8 NOT NULL,
|
|
24
|
-
uw_message text NOT NULL,
|
|
25
|
-
uw_stamp timestamp NOT NULL);
|
|
26
|
-
|
|
27
|
-
CREATE SEQUENCE uw_CreditnoteId_seq;
|
|
28
|
-
|
|
29
|
-
CREATE SEQUENCE uw_EnrollmentId_seq;
|
|
30
|
-
|
|
31
|
-
CREATE SEQUENCE uw_InvoiceId_seq;
|
|
32
|
-
|
|
33
|
-
CREATE SEQUENCE uw_PlaceholderInvoiceId_seq;
|
|
34
|
-
|
|
35
|
-
CREATE SEQUENCE uw_LessonId_seq;
|
|
36
|
-
|
|
37
|
-
CREATE SEQUENCE uw_LessongroupId_seq;
|
|
38
|
-
|
|
39
|
-
CREATE SEQUENCE uw_TextnoteId_seq;
|
|
40
|
-
|
|
41
|
-
CREATE SEQUENCE uw_FilenoteId_seq;
|
|
42
|
-
|
|
43
|
-
CREATE SEQUENCE uw_EnrollmentrequestId_seq;
|
|
44
|
-
|
|
45
|
-
CREATE SEQUENCE uw_EnrollmentrequestPrivateId_seq;
|
|
46
|
-
|
|
47
|
-
CREATE SEQUENCE uw_EmailId_seq;
|
|
48
|
-
|
|
49
|
-
CREATE SEQUENCE uw_EvaluationId_seq;
|
|
50
|
-
|
|
51
|
-
CREATE SEQUENCE uw_ReplyId_seq;
|
|
52
|
-
|
|
53
|
-
CREATE TABLE uw_Allowhomeandonlinelocations_tab(
|
|
54
|
-
uw_version int8 NOT NULL,
|
|
55
|
-
uw_value bool NOT NULL,
|
|
56
|
-
uw_islastversion bool NOT NULL,
|
|
57
|
-
uw_stamp timestamp NOT NULL);
|
|
58
|
-
|
|
59
|
-
CREATE TABLE uw_Oauth_authorizerequests(
|
|
60
|
-
uw_stamp timestamp NOT NULL,
|
|
61
|
-
uw_csrftoken text NOT NULL);
|
|
62
|
-
|
|
63
|
-
CREATE TABLE uw_Oauth_accesstokens(
|
|
64
|
-
uw_refreshtoken text NOT NULL,
|
|
65
|
-
uw_accesstoken text NOT NULL,
|
|
66
|
-
uw_createdat timestamp NOT NULL,
|
|
67
|
-
uw_expiresin int8 NOT NULL,
|
|
68
|
-
CONSTRAINT uw_Oauth_accesstokens_pkey PRIMARY KEY (uw_refreshToken));
|
|
69
|
-
|
|
70
|
-
CREATE TABLE uw_B2bucket_ID_tab(
|
|
71
|
-
uw_version int8 NOT NULL,
|
|
72
|
-
uw_value text NOT NULL,
|
|
73
|
-
uw_islastversion bool NOT NULL,
|
|
74
|
-
uw_stamp timestamp NOT NULL);
|
|
75
|
-
|
|
76
|
-
CREATE TABLE uw_B2bucket_Name__tab(
|
|
77
|
-
uw_version int8 NOT NULL,
|
|
78
|
-
uw_value text NOT NULL,
|
|
79
|
-
uw_islastversion bool NOT NULL,
|
|
80
|
-
uw_stamp timestamp NOT NULL);
|
|
81
|
-
|
|
82
|
-
CREATE TABLE uw_Invoiceduedate_tab(
|
|
83
|
-
uw_version int8 NOT NULL,
|
|
84
|
-
uw_value int8 NOT NULL,
|
|
85
|
-
uw_islastversion bool NOT NULL,
|
|
86
|
-
uw_stamp timestamp NOT NULL);
|
|
87
|
-
|
|
88
|
-
CREATE TABLE uw_Invoicepayduringenrollment_tab(
|
|
89
|
-
uw_version int8 NOT NULL,
|
|
90
|
-
uw_value bool NOT NULL,
|
|
91
|
-
uw_islastversion bool NOT NULL,
|
|
92
|
-
uw_stamp timestamp NOT NULL);
|
|
93
|
-
|
|
94
|
-
CREATE TABLE uw_Periodfeeduedate_tab(
|
|
95
|
-
uw_version int8 NOT NULL,
|
|
96
|
-
uw_value text NOT NULL,
|
|
97
|
-
uw_islastversion bool NOT NULL,
|
|
98
|
-
uw_stamp timestamp NOT NULL);
|
|
99
|
-
|
|
100
|
-
CREATE TABLE uw_Periodfeepayduringenrollment_tab(
|
|
101
|
-
uw_version int8 NOT NULL,
|
|
102
|
-
uw_value bool NOT NULL,
|
|
103
|
-
uw_islastversion bool NOT NULL,
|
|
104
|
-
uw_stamp timestamp NOT NULL);
|
|
105
|
-
|
|
106
|
-
CREATE TABLE uw_Teacherscanmanageinvoices_tab(
|
|
107
|
-
uw_version int8 NOT NULL,
|
|
108
|
-
uw_value bool NOT NULL,
|
|
109
|
-
uw_islastversion bool NOT NULL,
|
|
110
|
-
uw_stamp timestamp NOT NULL);
|
|
111
|
-
|
|
112
|
-
CREATE TABLE uw_Alwaysshowwireinstructions_tab(
|
|
113
|
-
uw_version int8 NOT NULL,
|
|
114
|
-
uw_value bool NOT NULL,
|
|
115
|
-
uw_islastversion bool NOT NULL,
|
|
116
|
-
uw_stamp timestamp NOT NULL);
|
|
117
|
-
|
|
118
|
-
CREATE SEQUENCE uw_Audit_trails;
|
|
119
|
-
|
|
120
|
-
CREATE TABLE uw_Audit_trail(
|
|
121
|
-
uw_id int8 NOT NULL,
|
|
122
|
-
uw_useremail text NOT NULL,
|
|
123
|
-
uw_type_ text NOT NULL,
|
|
124
|
-
uw_description text NOT NULL,
|
|
125
|
-
uw_extratechnicalinfo text NOT NULL,
|
|
126
|
-
uw_stamp timestamp NOT NULL);
|
|
127
|
-
|
|
128
|
-
CREATE SEQUENCE uw_Teacherid_seq;
|
|
129
|
-
|
|
130
|
-
CREATE SEQUENCE uw_Teacherid_internal_seq;
|
|
131
|
-
|
|
132
|
-
CREATE SEQUENCE uw_Teacherid_external_seq;
|
|
133
|
-
|
|
134
|
-
CREATE SEQUENCE uw_Studentid_seq;
|
|
135
|
-
|
|
136
|
-
CREATE SEQUENCE uw_Messageonstudentprofiles_MessageonstudentprofileId_seq;
|
|
137
|
-
|
|
138
|
-
CREATE TABLE uw_Messageonstudentprofiles_messageonstudentprofiles(
|
|
139
|
-
uw_id int8 NOT NULL,
|
|
140
|
-
uw_html text NOT NULL,
|
|
141
|
-
uw_text text NOT NULL,
|
|
142
|
-
uw_savedon timestamp NOT NULL,
|
|
143
|
-
uw_islastversion bool NOT NULL,
|
|
144
|
-
CONSTRAINT uw_Messageonstudentprofiles_messageonstudentprofiles_pkey
|
|
145
|
-
PRIMARY KEY (uw_id));
|
|
146
|
-
|
|
147
|
-
CREATE TABLE uw_Demoinstance_tab(
|
|
148
|
-
uw_version int8 NOT NULL,
|
|
149
|
-
uw_value bool NOT NULL,
|
|
150
|
-
uw_islastversion bool NOT NULL,
|
|
151
|
-
uw_stamp timestamp NOT NULL);
|
|
152
|
-
|
|
153
|
-
CREATE TABLE uw_Schoolname_SchoolnameSetting_tab(
|
|
154
|
-
uw_version int8 NOT NULL,
|
|
155
|
-
uw_value text NOT NULL,
|
|
156
|
-
uw_islastversion bool NOT NULL,
|
|
157
|
-
uw_stamp timestamp NOT NULL);
|
|
158
|
-
|
|
159
|
-
CREATE TABLE uw_Schoolcountry_Schoolcountryserialized_tab(
|
|
160
|
-
uw_version int8 NOT NULL,
|
|
161
|
-
uw_value text NOT NULL,
|
|
162
|
-
uw_islastversion bool NOT NULL,
|
|
163
|
-
uw_stamp timestamp NOT NULL);
|
|
164
|
-
|
|
165
|
-
CREATE TABLE uw_Adminaccounts_adminaccounts(
|
|
166
|
-
uw_email text NOT NULL,
|
|
167
|
-
uw_wantsnotificationsformessages bool NOT NULL,
|
|
168
|
-
uw_wantsccfornotes bool NOT NULL,
|
|
169
|
-
uw_wantsccformessages bool NOT NULL,
|
|
170
|
-
uw_sawwelcome bool NOT NULL,
|
|
171
|
-
CONSTRAINT uw_Adminaccounts_adminaccounts_pkey PRIMARY KEY (uw_email));
|
|
172
|
-
|
|
173
|
-
CREATE TABLE uw_Schoolhours_Schoolhoursserialized_tab(
|
|
174
|
-
uw_version int8 NOT NULL,
|
|
175
|
-
uw_value text NOT NULL,
|
|
176
|
-
uw_islastversion bool NOT NULL,
|
|
177
|
-
uw_stamp timestamp NOT NULL);
|
|
178
|
-
|
|
179
|
-
CREATE TABLE uw_Periodfee_tab(
|
|
180
|
-
uw_version int8 NOT NULL,
|
|
181
|
-
uw_value float8 NOT NULL,
|
|
182
|
-
uw_islastversion bool NOT NULL,
|
|
183
|
-
uw_stamp timestamp NOT NULL);
|
|
184
|
-
|
|
185
|
-
CREATE TABLE uw_Periodfeefamilydiscount_tab(
|
|
186
|
-
uw_version int8 NOT NULL,
|
|
187
|
-
uw_value float8 NOT NULL,
|
|
188
|
-
uw_islastversion bool NOT NULL,
|
|
189
|
-
uw_stamp timestamp NOT NULL);
|
|
190
|
-
|
|
191
|
-
CREATE TABLE uw_Schoolurl_tab(
|
|
192
|
-
uw_version int8 NOT NULL,
|
|
193
|
-
uw_value text NOT NULL,
|
|
194
|
-
uw_islastversion bool NOT NULL,
|
|
195
|
-
uw_stamp timestamp NOT NULL);
|
|
196
|
-
|
|
197
|
-
CREATE TABLE uw_Schoolaccount_tab(
|
|
198
|
-
uw_version int8 NOT NULL,
|
|
199
|
-
uw_value text,
|
|
200
|
-
uw_islastversion bool NOT NULL,
|
|
201
|
-
uw_stamp timestamp NOT NULL);
|
|
202
|
-
|
|
203
|
-
CREATE TABLE uw_Generalemail_tab(
|
|
204
|
-
uw_version int8 NOT NULL,
|
|
205
|
-
uw_value text,
|
|
206
|
-
uw_islastversion bool NOT NULL,
|
|
207
|
-
uw_stamp timestamp NOT NULL);
|
|
208
|
-
|
|
209
|
-
CREATE TABLE uw_Termsurl_tab(
|
|
210
|
-
uw_version int8 NOT NULL,
|
|
211
|
-
uw_value text,
|
|
212
|
-
uw_islastversion bool NOT NULL,
|
|
213
|
-
uw_stamp timestamp NOT NULL);
|
|
214
|
-
|
|
215
|
-
CREATE TABLE uw_Invoicedetails_tab(
|
|
216
|
-
uw_version int8 NOT NULL,
|
|
217
|
-
uw_value text,
|
|
218
|
-
uw_islastversion bool NOT NULL,
|
|
219
|
-
uw_stamp timestamp NOT NULL);
|
|
220
|
-
|
|
221
|
-
CREATE TABLE uw_Mollierefreshtoken_tab(
|
|
222
|
-
uw_version int8 NOT NULL,
|
|
223
|
-
uw_value text,
|
|
224
|
-
uw_islastversion bool NOT NULL,
|
|
225
|
-
uw_stamp timestamp NOT NULL);
|
|
226
|
-
|
|
227
|
-
CREATE TABLE uw_Mollieprofileid_tab(
|
|
228
|
-
uw_version int8 NOT NULL,
|
|
229
|
-
uw_value text,
|
|
230
|
-
uw_islastversion bool NOT NULL,
|
|
231
|
-
uw_stamp timestamp NOT NULL);
|
|
232
|
-
|
|
233
|
-
CREATE SEQUENCE uw_Config_periodsSeq;
|
|
234
|
-
|
|
235
|
-
CREATE TABLE uw_Config_periods(
|
|
236
|
-
uw_id int8 NOT NULL,
|
|
237
|
-
uw_firstday date NOT NULL,
|
|
238
|
-
uw_lastday date NOT NULL,
|
|
239
|
-
uw_lastdaytoenroll date NOT NULL,
|
|
240
|
-
CONSTRAINT uw_Config_periods_pkey PRIMARY KEY (uw_id));
|
|
241
|
-
|
|
242
|
-
CREATE TABLE uw_Config_holidays(
|
|
243
|
-
uw_description text NOT NULL,
|
|
244
|
-
uw_periodid int8 NOT NULL,
|
|
245
|
-
uw_firstday date NOT NULL,
|
|
246
|
-
uw_lastday date NOT NULL,
|
|
247
|
-
CONSTRAINT uw_Config_holidays_pkey PRIMARY KEY
|
|
248
|
-
(uw_periodId, uw_description),
|
|
249
|
-
CONSTRAINT uw_Config_holidays_PeriodId
|
|
250
|
-
FOREIGN KEY (uw_periodId) REFERENCES uw_Config_periods (uw_id) ON DELETE CASCADE);
|
|
251
|
-
|
|
252
|
-
CREATE TABLE uw_Config_instruments(
|
|
253
|
-
uw_description text NOT NULL,
|
|
254
|
-
uw_id int8 NOT NULL,
|
|
255
|
-
uw_showonpublicplanning bool NOT NULL,
|
|
256
|
-
CONSTRAINT uw_Config_instruments_pkey PRIMARY KEY (uw_id));
|
|
257
|
-
|
|
258
|
-
CREATE SEQUENCE uw_Config_instrumentsSeq;
|
|
259
|
-
|
|
260
|
-
CREATE SEQUENCE uw_Config_formulasSeq;
|
|
261
|
-
|
|
262
|
-
CREATE TABLE uw_Config_formulas(
|
|
263
|
-
uw_numberoflessons int8 NOT NULL,
|
|
264
|
-
uw_lessonduration int8 NOT NULL,
|
|
265
|
-
uw_startsfromperiod bool NOT NULL,
|
|
266
|
-
uw_manualplanning bool NOT NULL,
|
|
267
|
-
uw_description text NOT NULL,
|
|
268
|
-
uw_comments text NOT NULL,
|
|
269
|
-
uw_showonpublicplanning bool NOT NULL,
|
|
270
|
-
uw_type_ text NOT NULL,
|
|
271
|
-
uw_id int8 NOT NULL,
|
|
272
|
-
uw_color text NOT NULL,
|
|
273
|
-
CONSTRAINT uw_Config_formulas_pkey PRIMARY KEY (uw_id),
|
|
274
|
-
CONSTRAINT uw_Config_formulas_NumberOfLessons
|
|
275
|
-
CHECK (uw_numberOfLessons > 0::int8),
|
|
276
|
-
CONSTRAINT uw_Config_formulas_LessonDuration
|
|
277
|
-
CHECK ((uw_lessonDuration = 20::int8) OR ((uw_lessonDuration = 30::int8) OR ((uw_lessonDuration = 40::int8) OR ((uw_lessonDuration = 45::int8) OR ((uw_lessonDuration = 60::int8) OR ((uw_lessonDuration = 90::int8) OR ((uw_lessonDuration = 120::int8) OR ((uw_lessonDuration = 150::int8) OR (uw_lessonDuration = 180::int8))))))))));
|
|
278
|
-
|
|
279
|
-
CREATE TABLE uw_Config_formulainvoicelines(
|
|
280
|
-
uw_formulaid int8 NOT NULL,
|
|
281
|
-
uw_type_ text NOT NULL,
|
|
282
|
-
uw_description text NOT NULL,
|
|
283
|
-
uw_amount float8 NOT NULL,
|
|
284
|
-
uw_vat float8 NOT NULL,
|
|
285
|
-
uw_order int8 NOT NULL,
|
|
286
|
-
CONSTRAINT uw_Config_formulainvoicelines_pkey PRIMARY KEY
|
|
287
|
-
(uw_order, uw_formulaId),
|
|
288
|
-
CONSTRAINT uw_Config_formulainvoicelines_FormulaId
|
|
289
|
-
FOREIGN KEY (uw_formulaId) REFERENCES uw_Config_formulas (uw_id) ON DELETE CASCADE,
|
|
290
|
-
CONSTRAINT uw_Config_formulainvoicelines_VAT CHECK (uw_vAT >= 0::float8),
|
|
291
|
-
CONSTRAINT uw_Config_formulainvoicelines_Order CHECK (uw_order >= 0::int8));
|
|
292
|
-
|
|
293
|
-
CREATE TABLE uw_Config_formulainstruments(
|
|
294
|
-
uw_formulaid int8 NOT NULL,
|
|
295
|
-
uw_instrumentid int8 NOT NULL,
|
|
296
|
-
CONSTRAINT uw_Config_formulainstruments_pkey PRIMARY KEY
|
|
297
|
-
(uw_instrumentId, uw_formulaId),
|
|
298
|
-
CONSTRAINT uw_Config_formulainstruments_FormulaId
|
|
299
|
-
FOREIGN KEY (uw_formulaId) REFERENCES uw_Config_formulas (uw_id) ON DELETE CASCADE,
|
|
300
|
-
CONSTRAINT uw_Config_formulainstruments_InstrumentId
|
|
301
|
-
FOREIGN KEY (uw_instrumentId) REFERENCES uw_Config_instruments (uw_id) ON DELETE CASCADE);
|
|
302
|
-
|
|
303
|
-
CREATE SEQUENCE uw_Room_roomsseq;
|
|
304
|
-
|
|
305
|
-
CREATE TABLE uw_Room_rooms(
|
|
306
|
-
uw_id int8 NOT NULL,
|
|
307
|
-
uw_description text NOT NULL,
|
|
308
|
-
CONSTRAINT uw_Room_rooms_pkey PRIMARY KEY (uw_id));
|
|
309
|
-
|
|
310
|
-
CREATE TABLE uw_Room_roominstruments(
|
|
311
|
-
uw_roomid int8 NOT NULL,
|
|
312
|
-
uw_instrumentid int8 NOT NULL,
|
|
313
|
-
CONSTRAINT uw_Room_roominstruments_pkey PRIMARY KEY
|
|
314
|
-
(uw_instrumentId, uw_roomId),
|
|
315
|
-
CONSTRAINT uw_Room_roominstruments_RoomId
|
|
316
|
-
FOREIGN KEY (uw_roomId) REFERENCES uw_Room_rooms (uw_id) ON DELETE CASCADE,
|
|
317
|
-
CONSTRAINT uw_Room_roominstruments_InstrumentId
|
|
318
|
-
FOREIGN KEY (uw_instrumentId) REFERENCES uw_Config_instruments (uw_id) ON DELETE CASCADE);
|
|
319
|
-
|
|
320
|
-
CREATE TABLE uw_Teacher_teachers(
|
|
321
|
-
uw_id int8 NOT NULL,
|
|
322
|
-
uw_firstname text NOT NULL,
|
|
323
|
-
uw_lastname text NOT NULL,
|
|
324
|
-
uw_comments text NOT NULL,
|
|
325
|
-
uw_email text NOT NULL,
|
|
326
|
-
uw_phone text NOT NULL,
|
|
327
|
-
uw_wantsnotificationsformessages bool NOT NULL,
|
|
328
|
-
uw_wantsnotificationsfornotes bool NOT NULL,
|
|
329
|
-
CONSTRAINT uw_Teacher_teachers_pkey PRIMARY KEY (uw_id));
|
|
330
|
-
|
|
331
|
-
CREATE TABLE uw_Teacher_internalTeachers(
|
|
332
|
-
uw_internalteacherid int8 NOT NULL,
|
|
333
|
-
uw_id int8 NOT NULL,
|
|
334
|
-
uw_managesinvoices bool NOT NULL,
|
|
335
|
-
uw_active bool NOT NULL,
|
|
336
|
-
CONSTRAINT uw_Teacher_internalTeachers_pkey PRIMARY KEY
|
|
337
|
-
(uw_internalTeacherId),
|
|
338
|
-
CONSTRAINT uw_Teacher_internalTeachers_IntToTeacherId
|
|
339
|
-
FOREIGN KEY (uw_id) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE);
|
|
340
|
-
|
|
341
|
-
CREATE TABLE uw_Teacher_externalTeachers(
|
|
342
|
-
uw_externalteacherid int8 NOT NULL,
|
|
343
|
-
uw_id int8 NOT NULL,
|
|
344
|
-
CONSTRAINT uw_Teacher_externalTeachers_pkey PRIMARY KEY
|
|
345
|
-
(uw_externalTeacherId),
|
|
346
|
-
CONSTRAINT uw_Teacher_externalTeachers_ExtToTeacherId
|
|
347
|
-
FOREIGN KEY (uw_id) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE);
|
|
348
|
-
|
|
349
|
-
CREATE TABLE uw_Teacher_teachingPeriods(
|
|
350
|
-
uw_time time NOT NULL,
|
|
351
|
-
uw_duration int8 NOT NULL,
|
|
352
|
-
uw_weekday text NOT NULL,
|
|
353
|
-
uw_internalteacherid int8 NOT NULL,
|
|
354
|
-
uw_location text NOT NULL,
|
|
355
|
-
uw_roomid int8,
|
|
356
|
-
CONSTRAINT uw_Teacher_teachingPeriods_pkey PRIMARY KEY
|
|
357
|
-
(uw_time, uw_internalTeacherId, uw_weekday),
|
|
358
|
-
CONSTRAINT uw_Teacher_teachingPeriods_InternalTeacherId
|
|
359
|
-
FOREIGN KEY (uw_internalTeacherId) REFERENCES uw_Teacher_internalTeachers (uw_internalTeacherId) ON DELETE CASCADE,
|
|
360
|
-
CONSTRAINT uw_Teacher_teachingPeriods_RoomId
|
|
361
|
-
FOREIGN KEY (uw_roomId) REFERENCES uw_Room_rooms (uw_id) ON DELETE SET NULL);
|
|
362
|
-
|
|
363
|
-
CREATE TABLE uw_Teacher_teaches(
|
|
364
|
-
uw_internalteacherid int8 NOT NULL,
|
|
365
|
-
uw_instrumentid int8 NOT NULL,
|
|
366
|
-
CONSTRAINT uw_Teacher_teaches_pkey PRIMARY KEY
|
|
367
|
-
(uw_instrumentId, uw_internalTeacherId),
|
|
368
|
-
CONSTRAINT uw_Teacher_teaches_InstrumentId
|
|
369
|
-
FOREIGN KEY (uw_instrumentId) REFERENCES uw_Config_instruments (uw_id) ON DELETE CASCADE,
|
|
370
|
-
CONSTRAINT uw_Teacher_teaches_InternalTeacherId
|
|
371
|
-
FOREIGN KEY (uw_internalTeacherId) REFERENCES uw_Teacher_internalTeachers (uw_internalTeacherId) ON DELETE CASCADE);
|
|
372
|
-
|
|
373
|
-
CREATE VIEW
|
|
374
|
-
uw_Teacher_internalTeachersF
|
|
375
|
-
AS
|
|
376
|
-
SELECT T_InternalTeachers.uw_active AS uw_Active, T_Teachers.uw_comments AS uw_Comments, T_Teachers.uw_email AS uw_Email, T_Teachers.uw_firstName AS uw_FirstName, T_Teachers.uw_id AS uw_Id, T_InternalTeachers.uw_internalTeacherId AS uw_InternalTeacherId, T_Teachers.uw_lastName AS uw_LastName, T_InternalTeachers.uw_managesInvoices AS uw_ManagesInvoices, T_Teachers.uw_phone AS uw_Phone FROM uw_Teacher_teachers AS T_Teachers JOIN uw_Teacher_internalTeachers AS T_InternalTeachers ON (T_Teachers.uw_id = T_InternalTeachers.uw_id);
|
|
377
|
-
|
|
378
|
-
CREATE VIEW
|
|
379
|
-
uw_Teacher_externalTeachersF
|
|
380
|
-
AS
|
|
381
|
-
SELECT T_Teachers.uw_comments AS uw_Comments, T_Teachers.uw_email AS uw_Email, T_ExternalTeachers.uw_externalTeacherId AS uw_ExternalTeacherId, T_Teachers.uw_firstName AS uw_FirstName, T_Teachers.uw_id AS uw_Id, T_Teachers.uw_lastName AS uw_LastName, T_Teachers.uw_phone AS uw_Phone FROM uw_Teacher_teachers AS T_Teachers JOIN uw_Teacher_externalTeachers AS T_ExternalTeachers ON (T_Teachers.uw_id = T_ExternalTeachers.uw_id);
|
|
382
|
-
|
|
383
|
-
CREATE DOMAIN studentid AS int8;
|
|
384
|
-
|
|
385
|
-
CREATE TABLE uw_Student_students(
|
|
386
|
-
uw_id studentid NOT NULL,
|
|
387
|
-
uw_firstname text NOT NULL,
|
|
388
|
-
uw_lastname text NOT NULL,
|
|
389
|
-
uw_comments text NOT NULL,
|
|
390
|
-
uw_birthday date,
|
|
391
|
-
uw_street text NOT NULL,
|
|
392
|
-
uw_number text NOT NULL,
|
|
393
|
-
uw_bus text NOT NULL,
|
|
394
|
-
uw_zip text NOT NULL,
|
|
395
|
-
uw_city text NOT NULL,
|
|
396
|
-
CONSTRAINT uw_Student_students_pkey PRIMARY KEY (uw_id));
|
|
397
|
-
|
|
398
|
-
CREATE TABLE uw_Student_studentphones(
|
|
399
|
-
uw_id int8 NOT NULL,
|
|
400
|
-
uw_studentid studentid NOT NULL,
|
|
401
|
-
uw_number text NOT NULL,
|
|
402
|
-
uw_description text,
|
|
403
|
-
CONSTRAINT uw_Student_studentphones_pkey PRIMARY KEY (uw_id),
|
|
404
|
-
CONSTRAINT uw_Student_studentphones_StudentId
|
|
405
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
406
|
-
|
|
407
|
-
CREATE SEQUENCE uw_Student_studentphonesSeq;
|
|
408
|
-
|
|
409
|
-
CREATE TABLE uw_Student_studentemails(
|
|
410
|
-
uw_id int8 NOT NULL,
|
|
411
|
-
uw_studentid studentid NOT NULL,
|
|
412
|
-
uw_email text NOT NULL,
|
|
413
|
-
uw_wantsnotificationsformessages bool NOT NULL,
|
|
414
|
-
uw_wantsnotificationsfornotes bool NOT NULL,
|
|
415
|
-
CONSTRAINT uw_Student_studentemails_pkey PRIMARY KEY (uw_id),
|
|
416
|
-
CONSTRAINT uw_Student_studentemails_StudentId
|
|
417
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
418
|
-
|
|
419
|
-
CREATE SEQUENCE uw_Student_studentemailsSeq;
|
|
420
|
-
|
|
421
|
-
CREATE TABLE uw_Student_family(
|
|
422
|
-
uw_subject int8 NOT NULL,
|
|
423
|
-
uw_relation text NOT NULL,
|
|
424
|
-
uw_other int8 NOT NULL,
|
|
425
|
-
CONSTRAINT uw_Student_family_pkey PRIMARY KEY (uw_other, uw_subject),
|
|
426
|
-
CONSTRAINT uw_Student_family_Subject
|
|
427
|
-
FOREIGN KEY (uw_subject) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
428
|
-
CONSTRAINT uw_Student_family_Other
|
|
429
|
-
FOREIGN KEY (uw_other) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
430
|
-
|
|
431
|
-
CREATE TABLE uw_Student_notfamily(
|
|
432
|
-
uw_subject int8 NOT NULL,
|
|
433
|
-
uw_other int8 NOT NULL,
|
|
434
|
-
CONSTRAINT uw_Student_notfamily_pkey PRIMARY KEY (uw_other, uw_subject),
|
|
435
|
-
CONSTRAINT uw_Student_notfamily_Subject
|
|
436
|
-
FOREIGN KEY (uw_subject) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
437
|
-
CONSTRAINT uw_Student_notfamily_Other
|
|
438
|
-
FOREIGN KEY (uw_other) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
439
|
-
|
|
440
|
-
CREATE SEQUENCE uw_Messagequeue_seq;
|
|
441
|
-
|
|
442
|
-
CREATE TABLE uw_Messagequeue_queuedMessages(
|
|
443
|
-
uw_id int8 NOT NULL,
|
|
444
|
-
uw_content text NOT NULL,
|
|
445
|
-
CONSTRAINT uw_Messagequeue_queuedMessages_pkey PRIMARY KEY (uw_id));
|
|
446
|
-
|
|
447
|
-
CREATE SEQUENCE uw_Email_AttachmentId_seq;
|
|
448
|
-
|
|
449
|
-
CREATE TABLE uw_Email_emails(
|
|
450
|
-
uw_id int8 NOT NULL,
|
|
451
|
-
uw_externalid text NOT NULL,
|
|
452
|
-
uw_address text NOT NULL,
|
|
453
|
-
uw_addressee text NOT NULL,
|
|
454
|
-
uw_subject text NOT NULL,
|
|
455
|
-
uw_text text NOT NULL,
|
|
456
|
-
uw_html text,
|
|
457
|
-
uw_from text NOT NULL,
|
|
458
|
-
uw_replyto text,
|
|
459
|
-
CONSTRAINT uw_Email_emails_pkey PRIMARY KEY (uw_id));
|
|
460
|
-
|
|
461
|
-
CREATE TABLE uw_Email_attachments(
|
|
462
|
-
uw_id int8 NOT NULL,
|
|
463
|
-
uw_emailid int8 NOT NULL,
|
|
464
|
-
uw_filename text NOT NULL,
|
|
465
|
-
uw_content bytea NOT NULL,
|
|
466
|
-
CONSTRAINT uw_Email_attachments_pkey PRIMARY KEY (uw_id),
|
|
467
|
-
CONSTRAINT uw_Email_attachments_EmailId
|
|
468
|
-
FOREIGN KEY (uw_emailId) REFERENCES uw_Email_emails (uw_id) ON DELETE CASCADE);
|
|
469
|
-
|
|
470
|
-
CREATE TABLE uw_Email_statusses(
|
|
471
|
-
uw_emailid int8 NOT NULL,
|
|
472
|
-
uw_version int8 NOT NULL,
|
|
473
|
-
uw_status text NOT NULL,
|
|
474
|
-
uw_stamp timestamp NOT NULL,
|
|
475
|
-
uw_islastversion bool NOT NULL,
|
|
476
|
-
CONSTRAINT uw_Email_statusses_pkey PRIMARY KEY (uw_version, uw_emailId),
|
|
477
|
-
CONSTRAINT uw_Email_statusses_EmailId
|
|
478
|
-
FOREIGN KEY (uw_emailId) REFERENCES uw_Email_emails (uw_id) ON DELETE CASCADE);
|
|
479
|
-
|
|
480
|
-
CREATE SEQUENCE uw_Message_MessageId_seq;
|
|
481
|
-
|
|
482
|
-
CREATE TABLE uw_Message_messages(
|
|
483
|
-
uw_id int8 NOT NULL,
|
|
484
|
-
uw_senderadmin bool NOT NULL,
|
|
485
|
-
uw_senderteacherid int8,
|
|
486
|
-
uw_senderstudentid studentid,
|
|
487
|
-
uw_receiveradmin bool NOT NULL,
|
|
488
|
-
uw_receiverteacherid int8,
|
|
489
|
-
uw_receiverstudentid studentid,
|
|
490
|
-
uw_date date NOT NULL,
|
|
491
|
-
uw_time time NOT NULL,
|
|
492
|
-
uw_read bool NOT NULL,
|
|
493
|
-
uw_stamp timestamp NOT NULL,
|
|
494
|
-
uw_text text NOT NULL,
|
|
495
|
-
uw_emailsent bool NOT NULL,
|
|
496
|
-
CONSTRAINT uw_Message_messages_pkey PRIMARY KEY (uw_id),
|
|
497
|
-
CONSTRAINT uw_Message_messages_Sender
|
|
498
|
-
CHECK (((uw_senderAdmin = TRUE) AND ((uw_senderTeacherId IS NULL) AND (uw_senderStudentId IS NULL))) OR (((uw_senderAdmin = FALSE) AND ((NOT (uw_senderTeacherId IS NULL)) AND (uw_senderStudentId IS NULL))) OR ((uw_senderAdmin = FALSE) AND ((uw_senderTeacherId IS NULL) AND (NOT (uw_senderStudentId IS NULL)))))),
|
|
499
|
-
CONSTRAINT uw_Message_messages_Receiver
|
|
500
|
-
CHECK (((uw_receiverAdmin = TRUE) AND ((uw_receiverTeacherId IS NULL) AND (uw_receiverStudentId IS NULL))) OR (((uw_receiverAdmin = FALSE) AND ((NOT (uw_receiverTeacherId IS NULL)) AND (uw_receiverStudentId IS NULL))) OR ((uw_receiverAdmin = FALSE) AND ((uw_receiverTeacherId IS NULL) AND (NOT (uw_receiverStudentId IS NULL)))))),
|
|
501
|
-
CONSTRAINT uw_Message_messages_SenderTeacherId
|
|
502
|
-
FOREIGN KEY (uw_senderTeacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE,
|
|
503
|
-
CONSTRAINT uw_Message_messages_SenderStudentId
|
|
504
|
-
FOREIGN KEY (uw_senderStudentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
505
|
-
CONSTRAINT uw_Message_messages_ReceiverTeacherId
|
|
506
|
-
FOREIGN KEY (uw_receiverTeacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE,
|
|
507
|
-
CONSTRAINT uw_Message_messages_ReceiverStudentId
|
|
508
|
-
FOREIGN KEY (uw_receiverStudentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
509
|
-
|
|
510
|
-
CREATE TABLE uw_Message_messageemails(
|
|
511
|
-
uw_messageid int8 NOT NULL,
|
|
512
|
-
uw_emailid int8 NOT NULL,
|
|
513
|
-
CONSTRAINT uw_Message_messageemails_pkey PRIMARY KEY
|
|
514
|
-
(uw_emailId, uw_messageId),
|
|
515
|
-
CONSTRAINT uw_Message_messageemails_MessageId
|
|
516
|
-
FOREIGN KEY (uw_messageId) REFERENCES uw_Message_messages (uw_id) ON DELETE CASCADE,
|
|
517
|
-
CONSTRAINT uw_Message_messageemails_EmailId
|
|
518
|
-
FOREIGN KEY (uw_emailId) REFERENCES uw_Email_emails (uw_id) ON DELETE CASCADE);
|
|
519
|
-
|
|
520
|
-
CREATE TABLE uw_Message_repliesformessages(
|
|
521
|
-
uw_replyid int8 NOT NULL,
|
|
522
|
-
uw_replyidstring text NOT NULL,
|
|
523
|
-
uw_messageid int8 NOT NULL,
|
|
524
|
-
uw_secret text NOT NULL,
|
|
525
|
-
uw_toadmin bool NOT NULL,
|
|
526
|
-
CONSTRAINT uw_Message_repliesformessages_pkey PRIMARY KEY (uw_replyId),
|
|
527
|
-
CONSTRAINT uw_Message_repliesformessages_MessageId
|
|
528
|
-
FOREIGN KEY (uw_messageId) REFERENCES uw_Message_messages (uw_id) ON DELETE CASCADE);
|
|
529
|
-
|
|
530
|
-
CREATE VIEW
|
|
531
|
-
uw_Message_messagesWithCounterparties
|
|
532
|
-
AS
|
|
533
|
-
SELECT T_Messages.uw_date AS uw_Date, T_Messages.uw_emailSent AS uw_EmailSent, T_Messages.uw_id AS uw_Id, T_Messages.uw_read AS uw_Read, T_Messages.uw_receiverAdmin AS uw_ReceiverAdmin, T_Receiverstudents.uw_firstName AS uw_ReceiverStudentFirstName, T_Receiverstudents.uw_id AS uw_ReceiverStudentId, T_Receiverstudents.uw_lastName AS uw_ReceiverStudentLastName, T_Receiverteachers.uw_firstName AS uw_ReceiverTeacherFirstName, T_Receiverteachers.uw_id AS uw_ReceiverTeacherId, T_Receiverteachers.uw_lastName AS uw_ReceiverTeacherLastName, T_Messages.uw_senderAdmin AS uw_SenderAdmin, T_Senderstudents.uw_firstName AS uw_SenderStudentFirstName, T_Senderstudents.uw_id AS uw_SenderStudentId, T_Senderstudents.uw_lastName AS uw_SenderStudentLastName, T_Senderteachers.uw_firstName AS uw_SenderTeacherFirstName, T_Senderteachers.uw_id AS uw_SenderTeacherId, T_Senderteachers.uw_lastName AS uw_SenderTeacherLastName, T_Messages.uw_stamp AS uw_Stamp, T_Messages.uw_text AS uw_Text, T_Messages.uw_time AS uw_Time FROM uw_Message_messages AS T_Messages LEFT JOIN uw_Student_students AS T_Senderstudents ON ((T_Messages.uw_senderStudentId = T_Senderstudents.uw_id) OR ((T_Messages.uw_senderStudentId) IS NULL AND (T_Senderstudents.uw_id) IS NULL)) LEFT JOIN uw_Teacher_teachers AS T_Senderteachers ON ((T_Messages.uw_senderTeacherId = T_Senderteachers.uw_id) OR ((T_Messages.uw_senderTeacherId) IS NULL AND (T_Senderteachers.uw_id) IS NULL)) LEFT JOIN uw_Student_students AS T_Receiverstudents ON ((T_Messages.uw_receiverStudentId = T_Receiverstudents.uw_id) OR ((T_Messages.uw_receiverStudentId) IS NULL AND (T_Receiverstudents.uw_id) IS NULL)) LEFT JOIN uw_Teacher_teachers AS T_Receiverteachers ON ((T_Messages.uw_receiverTeacherId = T_Receiverteachers.uw_id) OR ((T_Messages.uw_receiverTeacherId) IS NULL AND (T_Receiverteachers.uw_id) IS NULL));
|
|
534
|
-
|
|
535
|
-
CREATE TABLE uw_Message_fullMessageReplies(
|
|
536
|
-
uw_messageid int8 NOT NULL,
|
|
537
|
-
uw_text text NOT NULL,
|
|
538
|
-
uw_bodyplain text NOT NULL,
|
|
539
|
-
CONSTRAINT uw_Message_fullMessageReplies_pkey PRIMARY KEY (uw_messageId));
|
|
540
|
-
|
|
541
|
-
CREATE TABLE uw_Lesson_lessongroups(
|
|
542
|
-
uw_id int8 NOT NULL,
|
|
543
|
-
uw_internalteacherid int8 NOT NULL,
|
|
544
|
-
uw_restlessons int8 NOT NULL,
|
|
545
|
-
uw_instrumentid int8 NOT NULL,
|
|
546
|
-
uw_lessonduration int8 NOT NULL,
|
|
547
|
-
uw_startsfromperiod bool NOT NULL,
|
|
548
|
-
uw_startsinperiod int8 NOT NULL,
|
|
549
|
-
uw_firstlesson date,
|
|
550
|
-
uw_lastlesson date,
|
|
551
|
-
uw_description text,
|
|
552
|
-
uw_formulaid int8 NOT NULL,
|
|
553
|
-
uw_complement int8,
|
|
554
|
-
uw_weekday text NOT NULL,
|
|
555
|
-
uw_time time NOT NULL,
|
|
556
|
-
uw_planningmode text NOT NULL,
|
|
557
|
-
uw_type_ text NOT NULL,
|
|
558
|
-
uw_location text NOT NULL,
|
|
559
|
-
uw_roomid int8,
|
|
560
|
-
CONSTRAINT uw_Lesson_lessongroups_pkey PRIMARY KEY (uw_id),
|
|
561
|
-
CONSTRAINT uw_Lesson_lessongroups_InternalTeacherId
|
|
562
|
-
FOREIGN KEY (uw_internalTeacherId) REFERENCES uw_Teacher_internalTeachers (uw_internalTeacherId) ON DELETE RESTRICT,
|
|
563
|
-
CONSTRAINT uw_Lesson_lessongroups_InstrumentId
|
|
564
|
-
FOREIGN KEY (uw_instrumentId) REFERENCES uw_Config_instruments (uw_id) ON DELETE RESTRICT,
|
|
565
|
-
CONSTRAINT uw_Lesson_lessongroups_StartsInPeriod
|
|
566
|
-
FOREIGN KEY (uw_startsInPeriod) REFERENCES uw_Config_periods (uw_id) ON DELETE RESTRICT,
|
|
567
|
-
CONSTRAINT uw_Lesson_lessongroups_RoomId
|
|
568
|
-
FOREIGN KEY (uw_roomId) REFERENCES uw_Room_rooms (uw_id) ON DELETE SET NULL,
|
|
569
|
-
CONSTRAINT uw_Lesson_lessongroups_Complement
|
|
570
|
-
FOREIGN KEY (uw_complement) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE SET NULL,
|
|
571
|
-
CONSTRAINT uw_Lesson_lessongroups_FormulaId
|
|
572
|
-
FOREIGN KEY (uw_formulaId) REFERENCES uw_Config_formulas (uw_id) ON DELETE RESTRICT);
|
|
573
|
-
|
|
574
|
-
CREATE TABLE uw_Lesson_lessongroupinvoicelines(
|
|
575
|
-
uw_lessongroupid int8 NOT NULL,
|
|
576
|
-
uw_type_ text NOT NULL,
|
|
577
|
-
uw_description text NOT NULL,
|
|
578
|
-
uw_amount float8 NOT NULL,
|
|
579
|
-
uw_vat float8 NOT NULL,
|
|
580
|
-
uw_order int8 NOT NULL,
|
|
581
|
-
CONSTRAINT uw_Lesson_lessongroupinvoicelines_pkey PRIMARY KEY
|
|
582
|
-
(uw_order, uw_lessongroupId),
|
|
583
|
-
CONSTRAINT uw_Lesson_lessongroupinvoicelines_LessongroupId
|
|
584
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE,
|
|
585
|
-
CONSTRAINT uw_Lesson_lessongroupinvoicelines_Order
|
|
586
|
-
CHECK (uw_order >= 0::int8),
|
|
587
|
-
CONSTRAINT uw_Lesson_lessongroupinvoicelines_VAT
|
|
588
|
-
CHECK (uw_vAT >= 0::float8));
|
|
589
|
-
|
|
590
|
-
CREATE TABLE uw_Lesson_enrollmentsincludingstopped(
|
|
591
|
-
uw_id int8 NOT NULL,
|
|
592
|
-
uw_studentid studentid NOT NULL,
|
|
593
|
-
uw_lessongroupid int8 NOT NULL,
|
|
594
|
-
uw_status text NOT NULL,
|
|
595
|
-
uw_created date NOT NULL,
|
|
596
|
-
uw_allowreenrollment bool NOT NULL,
|
|
597
|
-
CONSTRAINT uw_Lesson_enrollmentsincludingstopped_pkey PRIMARY KEY (uw_id),
|
|
598
|
-
CONSTRAINT uw_Lesson_enrollmentsincludingstopped_StudentId
|
|
599
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE RESTRICT,
|
|
600
|
-
CONSTRAINT uw_Lesson_enrollmentsincludingstopped_LessongroupId
|
|
601
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE);
|
|
602
|
-
|
|
603
|
-
CREATE TABLE uw_Lesson_enrollmentrequests(
|
|
604
|
-
uw_id int8 NOT NULL,
|
|
605
|
-
uw_studentid studentid NOT NULL,
|
|
606
|
-
uw_status text NOT NULL,
|
|
607
|
-
uw_secret text NOT NULL,
|
|
608
|
-
uw_created timestamp NOT NULL,
|
|
609
|
-
uw_updated timestamp NOT NULL,
|
|
610
|
-
uw_lessongroupid int8,
|
|
611
|
-
uw_enrollmentrequestprivateid int8,
|
|
612
|
-
uw_familydiscountname text,
|
|
613
|
-
uw_reserveduntil date,
|
|
614
|
-
uw_showonplanninguntil date,
|
|
615
|
-
uw_origin text NOT NULL,
|
|
616
|
-
CONSTRAINT uw_Lesson_enrollmentrequests_pkey PRIMARY KEY (uw_id),
|
|
617
|
-
CONSTRAINT uw_Lesson_enrollmentrequests_StudentId
|
|
618
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
619
|
-
CONSTRAINT uw_Lesson_enrollmentrequests_LessongroupId
|
|
620
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE,
|
|
621
|
-
CONSTRAINT uw_Lesson_enrollmentrequests_EitherLessongroupOrPrivate
|
|
622
|
-
CHECK (((uw_lessongroupId IS NULL) AND (NOT (uw_enrollmentrequestPrivateId IS NULL))) OR ((NOT (uw_lessongroupId IS NULL)) AND (uw_enrollmentrequestPrivateId IS NULL))));
|
|
623
|
-
|
|
624
|
-
CREATE TABLE uw_Lesson_privateenrollmentrequests(
|
|
625
|
-
uw_id int8 NOT NULL,
|
|
626
|
-
uw_firstlesson date NOT NULL,
|
|
627
|
-
uw_lastlesson date NOT NULL,
|
|
628
|
-
uw_startsinperiod int8 NOT NULL,
|
|
629
|
-
uw_weekday text NOT NULL,
|
|
630
|
-
uw_time time NOT NULL,
|
|
631
|
-
uw_formulaid int8 NOT NULL,
|
|
632
|
-
uw_instrumentid int8 NOT NULL,
|
|
633
|
-
uw_internalteacherid int8,
|
|
634
|
-
uw_enrollmentrequestid int8 NOT NULL,
|
|
635
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_pkey PRIMARY KEY (uw_id),
|
|
636
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_FormulaId
|
|
637
|
-
FOREIGN KEY (uw_formulaId) REFERENCES uw_Config_formulas (uw_id) ON DELETE CASCADE,
|
|
638
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_InstrumentId
|
|
639
|
-
FOREIGN KEY (uw_instrumentId) REFERENCES uw_Config_instruments (uw_id) ON DELETE CASCADE,
|
|
640
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_InternalTeacherId
|
|
641
|
-
FOREIGN KEY (uw_internalTeacherId) REFERENCES uw_Teacher_internalTeachers (uw_internalTeacherId) ON DELETE CASCADE,
|
|
642
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_EnrollmentrequestId
|
|
643
|
-
FOREIGN KEY (uw_enrollmentrequestId) REFERENCES uw_Lesson_enrollmentrequests (uw_id) ON DELETE CASCADE,
|
|
644
|
-
CONSTRAINT uw_Lesson_privateenrollmentrequests_StartsInPeriod
|
|
645
|
-
FOREIGN KEY (uw_startsInPeriod) REFERENCES uw_Config_periods (uw_id) ON DELETE RESTRICT);
|
|
646
|
-
|
|
647
|
-
CREATE TABLE uw_Lesson_lessonsincludingremoved(
|
|
648
|
-
uw_id int8 NOT NULL,
|
|
649
|
-
uw_lessongroupid int8 NOT NULL,
|
|
650
|
-
uw_plannedteacherid int8 NOT NULL,
|
|
651
|
-
uw_teacherid int8 NOT NULL,
|
|
652
|
-
uw_date date NOT NULL,
|
|
653
|
-
uw_time time NOT NULL,
|
|
654
|
-
uw_creation text NOT NULL,
|
|
655
|
-
uw_removedreason text,
|
|
656
|
-
uw_replacement int8,
|
|
657
|
-
uw_location text NOT NULL,
|
|
658
|
-
uw_roomid int8,
|
|
659
|
-
CONSTRAINT uw_Lesson_lessonsincludingremoved_pkey PRIMARY KEY (uw_id),
|
|
660
|
-
CONSTRAINT uw_Lesson_lessonsincludingremoved_LessongroupId
|
|
661
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE,
|
|
662
|
-
CONSTRAINT uw_Lesson_lessonsincludingremoved_TeacherId
|
|
663
|
-
FOREIGN KEY (uw_teacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE RESTRICT,
|
|
664
|
-
CONSTRAINT uw_Lesson_lessonsincludingremoved_Replacement
|
|
665
|
-
FOREIGN KEY (uw_replacement) REFERENCES uw_Lesson_lessonsincludingremoved (uw_id) ON DELETE SET NULL,
|
|
666
|
-
CONSTRAINT uw_Lesson_lessonsincludingremoved_RoomId
|
|
667
|
-
FOREIGN KEY (uw_roomId) REFERENCES uw_Room_rooms (uw_id) ON DELETE SET NULL);
|
|
668
|
-
|
|
669
|
-
CREATE VIEW
|
|
670
|
-
uw_Lesson_lessons
|
|
671
|
-
AS
|
|
672
|
-
SELECT T_Lessonsincludingremoved.uw_creation AS uw_Creation, T_Lessonsincludingremoved.uw_date AS uw_Date, T_Lessongroups.uw_lessonDuration AS uw_Duration, T_Lessonsincludingremoved.uw_id AS uw_Id, T_Lessonsincludingremoved.uw_lessongroupId AS uw_LessongroupId, T_Lessonsincludingremoved.uw_location AS uw_Location, T_Lessonsincludingremoved.uw_plannedTeacherId AS uw_PlannedTeacherId, T_Lessonsincludingremoved.uw_roomId AS uw_RoomId, T_Lessonsincludingremoved.uw_teacherId AS uw_TeacherId, T_Lessonsincludingremoved.uw_time AS uw_Time FROM uw_Lesson_lessonsincludingremoved AS T_Lessonsincludingremoved JOIN uw_Lesson_lessongroups AS T_Lessongroups ON (T_Lessongroups.uw_id = T_Lessonsincludingremoved.uw_lessongroupId) WHERE (T_Lessonsincludingremoved.uw_removedReason IS NULL);
|
|
673
|
-
|
|
674
|
-
CREATE TABLE uw_Lesson_holidaysskippedduringplanning(
|
|
675
|
-
uw_date date NOT NULL,
|
|
676
|
-
uw_holidaydescription text NOT NULL,
|
|
677
|
-
uw_lessongroupid int8 NOT NULL,
|
|
678
|
-
CONSTRAINT uw_Lesson_holidaysskippedduringplanning_pkey PRIMARY KEY
|
|
679
|
-
(uw_lessongroupId, uw_date),
|
|
680
|
-
CONSTRAINT uw_Lesson_holidaysskippedduringplanning_LessongroupId
|
|
681
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE);
|
|
682
|
-
|
|
683
|
-
CREATE TABLE uw_Lesson_finance_placeholderInvoices(
|
|
684
|
-
uw_id int8 NOT NULL,
|
|
685
|
-
uw_due date NOT NULL,
|
|
686
|
-
uw_enrollmentrequestid int8 NOT NULL,
|
|
687
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoices_pkey PRIMARY KEY (uw_id),
|
|
688
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoices_EnrollmentrequestId_Uniq
|
|
689
|
-
UNIQUE (uw_enrollmentrequestId));
|
|
690
|
-
|
|
691
|
-
CREATE TABLE uw_Lesson_finance_placeholderInvoicelines(
|
|
692
|
-
uw_placeholderinvoiceid int8 NOT NULL,
|
|
693
|
-
uw_description text NOT NULL,
|
|
694
|
-
uw_amount float8 NOT NULL,
|
|
695
|
-
uw_vat float8 NOT NULL,
|
|
696
|
-
uw_order int8 NOT NULL,
|
|
697
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoicelines_pkey PRIMARY KEY
|
|
698
|
-
(uw_order, uw_placeholderInvoiceId),
|
|
699
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoicelines_PlaceholderInvoiceId
|
|
700
|
-
FOREIGN KEY (uw_placeholderInvoiceId) REFERENCES uw_Lesson_finance_placeholderInvoices (uw_id) ON DELETE CASCADE,
|
|
701
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoicelines_Order_Valid
|
|
702
|
-
CHECK (uw_order >= 0::int8),
|
|
703
|
-
CONSTRAINT uw_Lesson_finance_placeholderInvoicelines_VAT_Valid
|
|
704
|
-
CHECK (uw_vAT >= 0::float8));
|
|
705
|
-
|
|
706
|
-
CREATE TABLE uw_Lesson_finance_invoices(
|
|
707
|
-
uw_id int8 NOT NULL,
|
|
708
|
-
uw_due date NOT NULL,
|
|
709
|
-
uw_externalid int8 NOT NULL,
|
|
710
|
-
uw_enrollmentrequestid int8,
|
|
711
|
-
uw_enrollmentid int8,
|
|
712
|
-
uw_externalidstring text NOT NULL,
|
|
713
|
-
CONSTRAINT uw_Lesson_finance_invoices_pkey PRIMARY KEY (uw_id),
|
|
714
|
-
CONSTRAINT uw_Lesson_finance_invoices_ExternalId_Valid
|
|
715
|
-
CHECK (uw_externalId > 0::int8),
|
|
716
|
-
CONSTRAINT uw_Lesson_finance_invoices_ExternalId_Unique
|
|
717
|
-
UNIQUE (uw_externalId),
|
|
718
|
-
CONSTRAINT uw_Lesson_finance_invoices_EnrollmentrequestId_Unique
|
|
719
|
-
UNIQUE (uw_enrollmentrequestId),
|
|
720
|
-
CONSTRAINT uw_Lesson_finance_invoices_EnrollmentId_Unique
|
|
721
|
-
UNIQUE (uw_enrollmentId));
|
|
722
|
-
|
|
723
|
-
CREATE TABLE uw_Lesson_finance_invoicelines(
|
|
724
|
-
uw_invoiceid int8 NOT NULL,
|
|
725
|
-
uw_description text NOT NULL,
|
|
726
|
-
uw_amount float8 NOT NULL,
|
|
727
|
-
uw_vat float8 NOT NULL,
|
|
728
|
-
uw_order int8 NOT NULL,
|
|
729
|
-
CONSTRAINT uw_Lesson_finance_invoicelines_pkey PRIMARY KEY
|
|
730
|
-
(uw_order, uw_invoiceId),
|
|
731
|
-
CONSTRAINT uw_Lesson_finance_invoicelines_InvoiceId
|
|
732
|
-
FOREIGN KEY (uw_invoiceId) REFERENCES uw_Lesson_finance_invoices (uw_id) ON DELETE CASCADE,
|
|
733
|
-
CONSTRAINT uw_Lesson_finance_invoicelines_Order_Valid
|
|
734
|
-
CHECK (uw_order >= 0::int8),
|
|
735
|
-
CONSTRAINT uw_Lesson_finance_invoicelines_VAT_Valid
|
|
736
|
-
CHECK (uw_vAT >= 0::float8));
|
|
737
|
-
|
|
738
|
-
CREATE TABLE uw_Lesson_finance_requestedoptionalinvoicelines(
|
|
739
|
-
uw_enrollmentrequestid int8 NOT NULL,
|
|
740
|
-
uw_description text NOT NULL,
|
|
741
|
-
uw_amount float8 NOT NULL,
|
|
742
|
-
CONSTRAINT uw_Lesson_finance_requestedoptionalinvoicelines_pkey PRIMARY KEY
|
|
743
|
-
(uw_amount, uw_enrollmentrequestId, uw_description),
|
|
744
|
-
CONSTRAINT
|
|
745
|
-
uw_Lesson_finance_requestedoptionalinvoicelines_EnrollmentrequestId
|
|
746
|
-
FOREIGN KEY (uw_enrollmentrequestId) REFERENCES uw_Lesson_enrollmentrequests (uw_id) ON DELETE CASCADE);
|
|
747
|
-
|
|
748
|
-
CREATE TABLE uw_Lesson_finance_creditnotes(
|
|
749
|
-
uw_externalid int8 NOT NULL,
|
|
750
|
-
uw_amount float8 NOT NULL,
|
|
751
|
-
uw_date date NOT NULL,
|
|
752
|
-
uw_id int8 NOT NULL,
|
|
753
|
-
uw_invoiceid int8 NOT NULL,
|
|
754
|
-
CONSTRAINT uw_Lesson_finance_creditnotes_pkey PRIMARY KEY (uw_id),
|
|
755
|
-
CONSTRAINT uw_Lesson_finance_creditnotes_InvoiceId
|
|
756
|
-
FOREIGN KEY (uw_invoiceId) REFERENCES uw_Lesson_finance_invoices (uw_id) ON DELETE CASCADE,
|
|
757
|
-
CONSTRAINT uw_Lesson_finance_creditnotes_Amount_Valid
|
|
758
|
-
CHECK (uw_amount >= 0::float8),
|
|
759
|
-
CONSTRAINT uw_Lesson_finance_creditnotes_ExternalId_Valid
|
|
760
|
-
CHECK (uw_externalId > 0::int8),
|
|
761
|
-
CONSTRAINT uw_Lesson_finance_creditnotes_ExternalId_Unique
|
|
762
|
-
UNIQUE (uw_externalId));
|
|
763
|
-
|
|
764
|
-
CREATE TABLE uw_Lesson_finance_payments(
|
|
765
|
-
uw_amount float8 NOT NULL,
|
|
766
|
-
uw_date date NOT NULL,
|
|
767
|
-
uw_paymentproviderid text,
|
|
768
|
-
uw_method text NOT NULL,
|
|
769
|
-
uw_invoiceid int8 NOT NULL,
|
|
770
|
-
CONSTRAINT uw_Lesson_finance_payments_InvoiceId
|
|
771
|
-
FOREIGN KEY (uw_invoiceId) REFERENCES uw_Lesson_finance_invoices (uw_id) ON DELETE CASCADE,
|
|
772
|
-
CONSTRAINT uw_Lesson_finance_payments_Amount CHECK (uw_amount >= 0::float8));
|
|
773
|
-
|
|
774
|
-
CREATE TABLE uw_Lesson_finance_periodfees(
|
|
775
|
-
uw_studentid int8 NOT NULL,
|
|
776
|
-
uw_periodid int8 NOT NULL,
|
|
777
|
-
uw_amount float8 NOT NULL,
|
|
778
|
-
uw_method text,
|
|
779
|
-
uw_familydiscount float8 NOT NULL,
|
|
780
|
-
uw_paid float8 NOT NULL,
|
|
781
|
-
uw_due date NOT NULL,
|
|
782
|
-
CONSTRAINT uw_Lesson_finance_periodfees_pkey PRIMARY KEY
|
|
783
|
-
(uw_periodId, uw_studentId),
|
|
784
|
-
CONSTRAINT uw_Lesson_finance_periodfees_StudentId
|
|
785
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
786
|
-
|
|
787
|
-
CREATE VIEW
|
|
788
|
-
uw_Lesson_finance_paymentsT
|
|
789
|
-
AS
|
|
790
|
-
SELECT T_Payments.uw_invoiceId AS uw_InvoiceId, SUM(T_Payments.uw_amount) AS uw_TotalAmount FROM uw_Lesson_finance_payments AS T_Payments GROUP BY T_Payments.uw_InvoiceId;
|
|
791
|
-
|
|
792
|
-
CREATE VIEW
|
|
793
|
-
uw_Lesson_finance_invoicelinesT
|
|
794
|
-
AS
|
|
795
|
-
SELECT T_Invoicelines.uw_invoiceId AS uw_InvoiceId, SUM(T_Invoicelines.uw_amount) AS uw_TotalAmount FROM uw_Lesson_finance_invoicelines AS T_Invoicelines GROUP BY T_Invoicelines.uw_InvoiceId;
|
|
796
|
-
|
|
797
|
-
CREATE VIEW
|
|
798
|
-
uw_Lesson_finance_creditnotesT
|
|
799
|
-
AS
|
|
800
|
-
SELECT T_Creditnotes.uw_invoiceId AS uw_InvoiceId, SUM(T_Creditnotes.uw_amount) AS uw_TotalAmount FROM uw_Lesson_finance_creditnotes AS T_Creditnotes GROUP BY T_Creditnotes.uw_InvoiceId;
|
|
801
|
-
|
|
802
|
-
CREATE TABLE uw_Lesson_status_studentpresences(
|
|
803
|
-
uw_lessonid int8 NOT NULL,
|
|
804
|
-
uw_studentid int8 NOT NULL,
|
|
805
|
-
uw_status text NOT NULL,
|
|
806
|
-
uw_createdby text NOT NULL,
|
|
807
|
-
uw_createdon date NOT NULL,
|
|
808
|
-
uw_comments text NOT NULL,
|
|
809
|
-
uw_storagefileid text,
|
|
810
|
-
uw_needsadmincheck bool NOT NULL,
|
|
811
|
-
CONSTRAINT uw_Lesson_status_studentpresences_pkey PRIMARY KEY
|
|
812
|
-
(uw_studentId, uw_lessonId),
|
|
813
|
-
CONSTRAINT uw_Lesson_status_studentpresences_LessonId
|
|
814
|
-
FOREIGN KEY (uw_lessonId) REFERENCES uw_Lesson_lessonsincludingremoved (uw_id) ON DELETE CASCADE,
|
|
815
|
-
CONSTRAINT uw_Lesson_status_studentpresences_StudentId
|
|
816
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE);
|
|
817
|
-
|
|
818
|
-
CREATE VIEW
|
|
819
|
-
uw_Lesson_extended_extendedLessonsView
|
|
820
|
-
AS
|
|
821
|
-
SELECT T_Lessonsincludingremoved.uw_creation AS uw_Creation, T_Lessonsincludingremoved.uw_date AS uw_Date, T_Lessongroups.uw_lessonDuration AS uw_Duration, T_Enrollmentsincludingstopped.uw_id AS uw_EnrollmentId, T_Enrollmentsincludingstopped.uw_status AS uw_EnrollmentStatus, T_Lessonsincludingremoved.uw_id AS uw_Id, T_Instruments.uw_description AS uw_InstrumentDescription, T_Instruments.uw_id AS uw_InstrumentId, T_Lessonsincludingremoved.uw_lessongroupId AS uw_LessongroupId, T_Lessongroups.uw_lastLesson AS uw_Lessongroups_LastLesson, T_Lessonsincludingremoved.uw_location AS uw_Location, T_PT.uw_firstName AS uw_PlannedTeacherFirstName, T_PT.uw_id AS uw_PlannedTeacherId, T_PT.uw_lastName AS uw_PlannedTeacherLastName, T_Lessonsincludingremoved.uw_removedReason AS uw_RemovedReason, T_Repl.uw_date AS uw_ReplacementDate, T_Repl.uw_time AS uw_ReplacementTime, T_Rooms.uw_description AS uw_RoomDescription, T_Lessonsincludingremoved.uw_roomId AS uw_RoomId, T_Studentpresences.uw_status AS uw_Status, T_Studentpresences.uw_comments AS uw_StatusComments, T_Studentpresences.uw_createdBy AS uw_StatusCreatedBy, T_Studentpresences.uw_createdOn AS uw_StatusCreatedOn, T_Studentpresences.uw_needsAdminCheck AS uw_StatusNeedsAdminCheck, T_Studentpresences.uw_storageFileId AS uw_StatusStorageFileId, T_Students.uw_firstName AS uw_StudentFirstName, T_Students.uw_id AS uw_StudentId, T_Students.uw_lastName AS uw_StudentLastName, T_TE.uw_firstName AS uw_TeacherFirstName, T_TE.uw_id AS uw_TeacherId, T_TE.uw_lastName AS uw_TeacherLastName, T_Lessonsincludingremoved.uw_time AS uw_Time, T_Lessongroups.uw_type_ AS uw_Type_ FROM uw_Lesson_lessonsincludingremoved AS T_Lessonsincludingremoved JOIN uw_Lesson_lessongroups AS T_Lessongroups ON (T_Lessonsincludingremoved.uw_lessongroupId = T_Lessongroups.uw_id) LEFT JOIN uw_Lesson_enrollmentsincludingstopped AS T_Enrollmentsincludingstopped ON (T_Enrollmentsincludingstopped.uw_lessongroupId = T_Lessongroups.uw_id) LEFT JOIN uw_Student_students AS T_Students ON ((T_Enrollmentsincludingstopped.uw_studentId = T_Students.uw_id) OR ((T_Enrollmentsincludingstopped.uw_studentId) IS NULL AND (T_Students.uw_id) IS NULL)) JOIN uw_Teacher_teachers AS T_TE ON (T_TE.uw_id = T_Lessonsincludingremoved.uw_teacherId) JOIN uw_Teacher_teachers AS T_PT ON (T_PT.uw_id = T_Lessonsincludingremoved.uw_plannedTeacherId) JOIN uw_Config_instruments AS T_Instruments ON (T_Instruments.uw_id = T_Lessongroups.uw_instrumentId) LEFT JOIN uw_Room_rooms AS T_Rooms ON ((T_Lessonsincludingremoved.uw_roomId = T_Rooms.uw_id) OR ((T_Lessonsincludingremoved.uw_roomId) IS NULL AND (T_Rooms.uw_id) IS NULL)) LEFT JOIN uw_Lesson_status_studentpresences AS T_Studentpresences ON ((T_Studentpresences.uw_lessonId = T_Lessonsincludingremoved.uw_id) AND ((T_Studentpresences.uw_studentId = T_Enrollmentsincludingstopped.uw_studentId) OR ((T_Studentpresences.uw_studentId) IS NULL AND (T_Enrollmentsincludingstopped.uw_studentId) IS NULL))) LEFT JOIN uw_Lesson_lessonsincludingremoved AS T_Repl ON ((T_Repl.uw_id = T_Lessonsincludingremoved.uw_replacement) OR ((T_Repl.uw_id) IS NULL AND (T_Lessonsincludingremoved.uw_replacement) IS NULL));
|
|
822
|
-
|
|
823
|
-
CREATE TABLE uw_Note_textnotes(
|
|
824
|
-
uw_id int8 NOT NULL,
|
|
825
|
-
uw_lessonid int8 NOT NULL,
|
|
826
|
-
uw_content text NOT NULL,
|
|
827
|
-
uw_studentid int8,
|
|
828
|
-
uw_teacherid int8,
|
|
829
|
-
uw_stamp timestamp NOT NULL,
|
|
830
|
-
CONSTRAINT uw_Note_textnotes_pkey PRIMARY KEY (uw_id),
|
|
831
|
-
CONSTRAINT uw_Note_textnotes_LessonId
|
|
832
|
-
FOREIGN KEY (uw_lessonId) REFERENCES uw_Lesson_lessonsincludingremoved (uw_id) ON DELETE CASCADE,
|
|
833
|
-
CONSTRAINT uw_Note_textnotes_StudentId
|
|
834
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
835
|
-
CONSTRAINT uw_Note_textnotes_TeacherId
|
|
836
|
-
FOREIGN KEY (uw_teacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE);
|
|
837
|
-
|
|
838
|
-
CREATE TABLE uw_Note_filenotes(
|
|
839
|
-
uw_id int8 NOT NULL,
|
|
840
|
-
uw_lessonid int8 NOT NULL,
|
|
841
|
-
uw_description text NOT NULL,
|
|
842
|
-
uw_studentid int8,
|
|
843
|
-
uw_teacherid int8,
|
|
844
|
-
uw_stamp timestamp NOT NULL,
|
|
845
|
-
uw_mimetype text NOT NULL,
|
|
846
|
-
uw_storagefileid text NOT NULL,
|
|
847
|
-
CONSTRAINT uw_Note_filenotes_pkey PRIMARY KEY (uw_id),
|
|
848
|
-
CONSTRAINT uw_Note_filenotes_LessonId
|
|
849
|
-
FOREIGN KEY (uw_lessonId) REFERENCES uw_Lesson_lessonsincludingremoved (uw_id) ON DELETE CASCADE,
|
|
850
|
-
CONSTRAINT uw_Note_filenotes_StudentId
|
|
851
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
852
|
-
CONSTRAINT uw_Note_filenotes_TeacherId
|
|
853
|
-
FOREIGN KEY (uw_teacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE);
|
|
854
|
-
|
|
855
|
-
CREATE TABLE uw_Note_repliesfornotes(
|
|
856
|
-
uw_replyid int8 NOT NULL,
|
|
857
|
-
uw_replyidstring text NOT NULL,
|
|
858
|
-
uw_lessonid int8 NOT NULL,
|
|
859
|
-
uw_studentid int8,
|
|
860
|
-
uw_teacherid int8,
|
|
861
|
-
uw_admin bool NOT NULL,
|
|
862
|
-
uw_secret text NOT NULL,
|
|
863
|
-
CONSTRAINT uw_Note_repliesfornotes_pkey PRIMARY KEY (uw_replyId),
|
|
864
|
-
CONSTRAINT uw_Note_repliesfornotes_LessonId
|
|
865
|
-
FOREIGN KEY (uw_lessonId) REFERENCES uw_Lesson_lessonsincludingremoved (uw_id) ON DELETE CASCADE,
|
|
866
|
-
CONSTRAINT uw_Note_repliesfornotes_StudentId
|
|
867
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
868
|
-
CONSTRAINT uw_Note_repliesfornotes_TeacherId
|
|
869
|
-
FOREIGN KEY (uw_teacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE,
|
|
870
|
-
CONSTRAINT uw_Note_repliesfornotes_Receiver
|
|
871
|
-
CHECK (((uw_admin = TRUE) AND ((uw_teacherId IS NULL) AND (uw_studentId IS NULL))) OR (((uw_admin = FALSE) AND ((NOT (uw_teacherId IS NULL)) AND (uw_studentId IS NULL))) OR ((uw_admin = FALSE) AND ((uw_teacherId IS NULL) AND (NOT (uw_studentId IS NULL)))))));
|
|
872
|
-
|
|
873
|
-
CREATE SEQUENCE uw_Note_viewednotesSeq;
|
|
874
|
-
|
|
875
|
-
CREATE TABLE uw_Note_viewednotes(
|
|
876
|
-
uw_id int8 NOT NULL,
|
|
877
|
-
uw_teacherid int8,
|
|
878
|
-
uw_studentid int8,
|
|
879
|
-
uw_lessongroupid int8 NOT NULL,
|
|
880
|
-
uw_stamp timestamp NOT NULL,
|
|
881
|
-
CONSTRAINT uw_Note_viewednotes_pkey PRIMARY KEY (uw_id),
|
|
882
|
-
CONSTRAINT uw_Note_viewednotes_TeacherId
|
|
883
|
-
FOREIGN KEY (uw_teacherId) REFERENCES uw_Teacher_teachers (uw_id) ON DELETE CASCADE,
|
|
884
|
-
CONSTRAINT uw_Note_viewednotes_StudentId
|
|
885
|
-
FOREIGN KEY (uw_studentId) REFERENCES uw_Student_students (uw_id) ON DELETE CASCADE,
|
|
886
|
-
CONSTRAINT uw_Note_viewednotes_LessongroupId
|
|
887
|
-
FOREIGN KEY (uw_lessongroupId) REFERENCES uw_Lesson_lessongroups (uw_id) ON DELETE CASCADE,
|
|
888
|
-
CONSTRAINT uw_Note_viewednotes_TeacherOrStudent
|
|
889
|
-
CHECK (((uw_teacherId IS NULL) AND (NOT (uw_studentId IS NULL))) OR ((uw_studentId IS NULL) AND (NOT (uw_teacherId IS NULL)))));
|
|
890
|
-
|
|
891
|
-
CREATE VIEW
|
|
892
|
-
uw_Note_notestamps
|
|
893
|
-
AS
|
|
894
|
-
((SELECT T_Textnotes.uw_lessonId AS uw_LessonId, T_Textnotes.uw_stamp AS uw_Stamp FROM uw_Note_textnotes AS T_Textnotes) UNION (SELECT T_Filenotes.uw_lessonId AS uw_LessonId, T_Filenotes.uw_stamp AS uw_Stamp FROM uw_Note_filenotes AS T_Filenotes));
|
|
895
|
-
|
|
896
|
-
CREATE TABLE uw_Session_credentials(
|
|
897
|
-
uw_email text NOT NULL,
|
|
898
|
-
uw_hash text NOT NULL,
|
|
899
|
-
uw_createdon timestamp NOT NULL,
|
|
900
|
-
CONSTRAINT uw_Session_credentials_pkey PRIMARY KEY (uw_email));
|
|
901
|
-
|
|
902
|
-
CREATE TABLE uw_Session_resettingcredentials(
|
|
903
|
-
uw_email text NOT NULL,
|
|
904
|
-
uw_since timestamp NOT NULL,
|
|
905
|
-
uw_random int8 NOT NULL,
|
|
906
|
-
CONSTRAINT uw_Session_resettingcredentials_pkey PRIMARY KEY (uw_email));
|
|
907
|
-
|
|
908
|
-
CREATE TABLE uw_Session_Emailsecret_secrets(
|
|
909
|
-
uw_email text NOT NULL,
|
|
910
|
-
uw_secret text NOT NULL,
|
|
911
|
-
uw_stamp timestamp NOT NULL,
|
|
912
|
-
CONSTRAINT uw_Session_Emailsecret_secrets_pkey PRIMARY KEY
|
|
913
|
-
(uw_stamp, uw_email));
|
|
914
|
-
|
|
915
|
-
CREATE SEQUENCE uw_Event_EventId_seq;
|
|
916
|
-
|
|
917
|
-
CREATE TABLE uw_Event_events(
|
|
918
|
-
uw_id int8 NOT NULL,
|
|
919
|
-
uw_description text NOT NULL,
|
|
920
|
-
uw_text text NOT NULL,
|
|
921
|
-
uw_html text NOT NULL,
|
|
922
|
-
uw_attachment text,
|
|
923
|
-
uw_attachmentname text,
|
|
924
|
-
uw_date date NOT NULL,
|
|
925
|
-
CONSTRAINT uw_Event_events_pkey PRIMARY KEY (uw_id));
|
|
926
|
-
|
|
927
|
-
CREATE SEQUENCE uw_Evaluation_EvaluationSectionId_seq;
|
|
928
|
-
|
|
929
|
-
CREATE TABLE uw_Evaluation_evaluations(
|
|
930
|
-
uw_id int8 NOT NULL,
|
|
931
|
-
uw_enrollmentid int8 NOT NULL,
|
|
932
|
-
uw_created date NOT NULL,
|
|
933
|
-
uw_modified date NOT NULL,
|
|
934
|
-
uw_finalized date,
|
|
935
|
-
CONSTRAINT uw_Evaluation_evaluations_pkey PRIMARY KEY (uw_id),
|
|
936
|
-
CONSTRAINT uw_Evaluation_evaluations_EnrollmentId
|
|
937
|
-
FOREIGN KEY (uw_enrollmentId) REFERENCES uw_Lesson_enrollmentsincludingstopped (uw_id) ON DELETE CASCADE);
|
|
938
|
-
|
|
939
|
-
CREATE TABLE uw_Evaluation_evaluationSections(
|
|
940
|
-
uw_id int8 NOT NULL,
|
|
941
|
-
uw_evaluationid int8 NOT NULL,
|
|
942
|
-
uw_title text NOT NULL,
|
|
943
|
-
uw_text text NOT NULL,
|
|
944
|
-
CONSTRAINT uw_Evaluation_evaluationSections_pkey PRIMARY KEY (uw_id),
|
|
945
|
-
CONSTRAINT uw_Evaluation_evaluationSections_EvaluationId
|
|
946
|
-
FOREIGN KEY (uw_evaluationId) REFERENCES uw_Evaluation_evaluations (uw_id) ON DELETE CASCADE);
|
|
947
|
-
|
|
948
|
-
CREATE TABLE uw_Payenrollment_onlinepayments(
|
|
949
|
-
uw_paymentid text NOT NULL,
|
|
950
|
-
uw_checkouturl text NOT NULL,
|
|
951
|
-
uw_enrollmentid int8,
|
|
952
|
-
uw_enrollmentrequestid int8,
|
|
953
|
-
uw_amount float8 NOT NULL,
|
|
954
|
-
uw_createdon timestamp NOT NULL,
|
|
955
|
-
uw_status text NOT NULL,
|
|
956
|
-
uw_description text NOT NULL,
|
|
957
|
-
CONSTRAINT uw_Payenrollment_onlinepayments_pkey PRIMARY KEY (uw_paymentId),
|
|
958
|
-
CONSTRAINT uw_Payenrollment_onlinepayments_EnrollmentOrRequest
|
|
959
|
-
CHECK (((uw_enrollmentId IS NULL) AND (NOT (uw_enrollmentrequestId IS NULL))) OR ((uw_enrollmentrequestId IS NULL) AND (NOT (uw_enrollmentId IS NULL)))));
|
|
960
|
-
|
|
961
|
-
CREATE OR REPLACE FUNCTION getEmailsToSend() RETURNS SETOF RECORD AS $$
|
|
962
|
-
SELECT
|
|
963
|
-
e.uw_id,
|
|
964
|
-
e.uw_from,
|
|
965
|
-
e.uw_replyto,
|
|
966
|
-
e.uw_address,
|
|
967
|
-
e.uw_addressee,
|
|
968
|
-
e.uw_subject,
|
|
969
|
-
e.uw_text,
|
|
970
|
-
e.uw_html,
|
|
971
|
-
e.uw_externalid,
|
|
972
|
-
a.uw_filename,
|
|
973
|
-
a.uw_content
|
|
974
|
-
FROM uw_email_emails e
|
|
975
|
-
JOIN uw_email_statusses s ON e.uw_id = s.uw_emailid AND s.uw_islastversion = TRUE
|
|
976
|
-
LEFT OUTER JOIN uw_email_attachments a ON a.uw_emailid = e.uw_id
|
|
977
|
-
WHERE s.uw_status = 'Waiting/_'
|
|
978
|
-
AND e.uw_html IS NOT NULL -- NULL = ARCHIVED
|
|
979
|
-
$$ LANGUAGE sql;
|
|
980
|
-
|
|
981
|
-
CREATE OR REPLACE FUNCTION insertNewEmailStatus(uw_emailid int, version int, uw_status text) RETURNS bigint AS $$
|
|
982
|
-
INSERT INTO uw_email_statusses
|
|
983
|
-
(uw_emailid, uw_version, uw_status, uw_stamp, uw_islastversion)
|
|
984
|
-
VALUES
|
|
985
|
-
(uw_emailid, version, uw_status, CURRENT_TIMESTAMP, TRUE)
|
|
986
|
-
RETURNING uw_emailid;
|
|
987
|
-
$$ LANGUAGE sql;
|
|
988
|
-
|
|
989
|
-
CREATE OR REPLACE FUNCTION getStudent(uw_studentid studentid) RETURNS RECORD AS $$
|
|
990
|
-
|
|
991
|
-
SELECT s.uw_firstname, s.uw_lastname, s.uw_birthday, emails.emails AS emails
|
|
992
|
-
FROM uw_student_students s
|
|
993
|
-
LEFT JOIN (SELECT em.uw_studentid, array_agg(json_build_object('id', em.uw_id, 'email', em.uw_email)) as emails
|
|
994
|
-
from uw_student_studentemails em
|
|
995
|
-
group by uw_studentid
|
|
996
|
-
) emails ON s.uw_id = emails.uw_studentid;
|
|
997
|
-
|
|
998
|
-
$$ LANGUAGE sql;
|
|
999
|
-
|
|
1000
|
-
CREATE OR REPLACE FUNCTION getStudentNestedJoin(uw_studentid studentid) RETURNS RECORD AS $$
|
|
1001
|
-
|
|
1002
|
-
SELECT
|
|
1003
|
-
s.uw_firstname,
|
|
1004
|
-
s.uw_lastname,
|
|
1005
|
-
(SELECT array_agg(json_build_object('id', em.uw_id, 'email', em.uw_email)) as emails
|
|
1006
|
-
from uw_student_studentemails em
|
|
1007
|
-
where em.uw_studentid = s.uw_id
|
|
1008
|
-
group by uw_studentid) AS emails,
|
|
1009
|
-
(SELECT array_agg(json_build_object('id', mess.uw_id, 'date', uw_date ,'time', uw_time, 'text', mess.uw_text)) as messages
|
|
1010
|
-
from uw_message_messages mess
|
|
1011
|
-
where mess.uw_receiverstudentid = s.uw_id
|
|
1012
|
-
group by uw_receiverstudentid) AS messages
|
|
1013
|
-
FROM uw_student_students s
|
|
1014
|
-
|
|
1015
|
-
$$ LANGUAGE sql;
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
CREATE OR REPLACE FUNCTION getStudentNestedJoinNoJson(uw_studentid studentid) RETURNS RECORD AS $$
|
|
1019
|
-
SELECT
|
|
1020
|
-
s.uw_firstname,
|
|
1021
|
-
s.uw_lastname,
|
|
1022
|
-
(SELECT array_agg(em.uw_email)
|
|
1023
|
-
from uw_student_studentemails em
|
|
1024
|
-
where em.uw_studentid = s.uw_id
|
|
1025
|
-
group by uw_studentid) AS emails
|
|
1026
|
-
FROM uw_student_students s
|
|
1027
|
-
$$ LANGUAGE sql;
|
|
1028
|
-
|
|
1029
|
-
CREATE OR REPLACE FUNCTION getStudentWithCtes(uw_studentid studentid) RETURNS RECORD AS $$
|
|
1030
|
-
|
|
1031
|
-
WITH emails AS (SELECT uw_studentid,
|
|
1032
|
-
array_agg(
|
|
1033
|
-
json_build_object('id', uw_id,
|
|
1034
|
-
'email', uw_email))
|
|
1035
|
-
FROM uw_student_studentemails
|
|
1036
|
-
GROUP BY uw_studentid
|
|
1037
|
-
),
|
|
1038
|
-
messages AS (SELECT uw_receiverstudentid,
|
|
1039
|
-
array_agg(
|
|
1040
|
-
json_build_object('id', uw_id,
|
|
1041
|
-
'date', uw_date,
|
|
1042
|
-
'time', uw_time,
|
|
1043
|
-
'text', uw_text))
|
|
1044
|
-
FROM uw_message_messages
|
|
1045
|
-
GROUP BY uw_receiverstudentid)
|
|
1046
|
-
SELECT
|
|
1047
|
-
s.uw_firstname, s.uw_lastname, s.uw_birthday,
|
|
1048
|
-
COALESCE(emails.array_agg, '{}') AS emails,
|
|
1049
|
-
COALESCE(messages.array_agg, '{}') AS messages
|
|
1050
|
-
FROM uw_student_students s
|
|
1051
|
-
LEFT JOIN emails ON s.uw_id = emails.uw_studentid
|
|
1052
|
-
LEFT JOIN messages ON s.uw_id = messages.uw_receiverstudentid
|
|
1053
|
-
WHERE s.uw_id = uw_studentid ;
|
|
1054
|
-
|
|
1055
|
-
$$ LANGUAGE sql;
|