936
by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was |
1 |
CREATE SEQUENCE login_unixid_seq MINVALUE 1000 MAXVALUE 29999 START WITH 5000; |
2 |
||
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
3 |
CREATE TABLE login ( |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
4 |
loginid SERIAL PRIMARY KEY NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
5 |
login VARCHAR UNIQUE NOT NULL, |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
6 |
passhash VARCHAR, |
475
by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to |
7 |
state VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending', |
1080.1.69
by William Grant
userdb: login.state now defaults to 'no_agreement'. |
8 |
'enabled', 'disabled')) |
9 |
DEFAULT 'no_agreement', |
|
533
by mattgiuca
auth/authenticate: Much done! |
10 |
rolenm VARCHAR NOT NULL CHECK (rolenm in ('anyone', 'student', |
11 |
'marker', 'tutor', |
|
12 |
'lecturer', 'admin')), |
|
936
by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was |
13 |
unixid INT UNIQUE DEFAULT nextval('login_unixid_seq') NOT NULL, |
475
by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to |
14 |
nick VARCHAR NOT NULL, |
15 |
pass_exp TIMESTAMP, |
|
16 |
acct_exp TIMESTAMP, |
|
17 |
last_login TIMESTAMP, |
|
522
by drtomc
Add quite a lot of stuff to get usrmgt happening. |
18 |
svn_pass VARCHAR, |
462
by mattgiuca
userdb/users.sql: Added email field to login. |
19 |
email VARCHAR, |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
20 |
fullname VARCHAR NOT NULL, |
631
by mattgiuca
users.sql: Added "settings" field to the login table. |
21 |
studentid VARCHAR, -- may be null |
22 |
settings VARCHAR |
|
25
by drtomc
A bit more work on the userdb stuff. |
23 |
);
|
24 |
||
935
by wagrant
userdb: Large changes: |
25 |
-- Subjects
|
26 |
-- --------
|
|
27 |
||
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
28 |
CREATE TABLE subject ( |
29 |
subjectid SERIAL PRIMARY KEY NOT NULL, |
|
30 |
subj_code VARCHAR UNIQUE NOT NULL, |
|
31 |
subj_name VARCHAR NOT NULL, |
|
916
by mattgiuca
userdb: Added constraints UNIQUE and NOT NULL to subjects.subj_short_name. |
32 |
subj_short_name VARCHAR UNIQUE NOT NULL, |
817
by mattgiuca
users.sql: Moved url from offering to subjects table. |
33 |
url VARCHAR |
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
34 |
);
|
35 |
||
935
by wagrant
userdb: Large changes: |
36 |
CREATE TABLE semester ( |
37 |
semesterid SERIAL PRIMARY KEY NOT NULL, |
|
38 |
year CHAR(4) NOT NULL, |
|
39 |
semester CHAR(1) NOT NULL, |
|
40 |
active BOOL NOT NULL, |
|
41 |
UNIQUE (year, semester) |
|
42 |
);
|
|
43 |
||
44 |
CREATE OR REPLACE FUNCTION deactivate_semester_enrolments_update() |
|
45 |
RETURNS trigger AS ' |
|
46 |
BEGIN
|
|
47 |
IF OLD.active = true AND NEW.active = false THEN
|
|
48 |
UPDATE enrolment SET active=false WHERE offeringid IN (
|
|
49 |
SELECT offeringid FROM offering WHERE offering.semesterid = NEW.semesterid);
|
|
50 |
END IF;
|
|
51 |
RETURN NULL;
|
|
52 |
END;
|
|
53 |
' LANGUAGE 'plpgsql'; |
|
54 |
||
55 |
CREATE TRIGGER deactivate_semester_enrolments |
|
56 |
AFTER UPDATE ON semester |
|
57 |
FOR EACH ROW EXECUTE PROCEDURE deactivate_semester_enrolments_update(); |
|
58 |
||
353
by drtomc
Start addressing sb's suggestions. |
59 |
CREATE TABLE offering ( |
324
by drtomc
Should all be okay now. |
60 |
offeringid SERIAL PRIMARY KEY NOT NULL, |
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
61 |
subject INT4 REFERENCES subject (subjectid) NOT NULL, |
935
by wagrant
userdb: Large changes: |
62 |
semesterid INTEGER REFERENCES semester (semesterid) NOT NULL, |
63 |
groups_student_permissions VARCHAR NOT NULL DEFAULT 'none', |
|
64 |
CHECK (groups_student_permissions in ('none', 'invite', 'create')), |
|
65 |
UNIQUE (subject, semesterid) |
|
66 |
);
|
|
67 |
||
68 |
-- Projects and groups
|
|
69 |
-- -------------------
|
|
70 |
||
71 |
CREATE TABLE project_set ( |
|
72 |
projectsetid SERIAL PRIMARY KEY NOT NULL, |
|
73 |
offeringid INTEGER REFERENCES offering (offeringid) NOT NULL, |
|
74 |
max_students_per_group INTEGER NOT NULL DEFAULT 4 |
|
324
by drtomc
Should all be okay now. |
75 |
);
|
76 |
||
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
77 |
CREATE TABLE project ( |
78 |
projectid SERIAL PRIMARY KEY NOT NULL, |
|
79 |
synopsis VARCHAR, |
|
80 |
url VARCHAR, |
|
935
by wagrant
userdb: Large changes: |
81 |
projectsetid INTEGER REFERENCES project_set (projectsetid) NOT NULL, |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
82 |
deadline TIMESTAMP |
83 |
);
|
|
84 |
||
85 |
CREATE TABLE project_group ( |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
86 |
groupnm VARCHAR NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
87 |
groupid SERIAL PRIMARY KEY NOT NULL, |
935
by wagrant
userdb: Large changes: |
88 |
projectsetid INTEGER REFERENCES project_set (projectsetid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
89 |
nick VARCHAR, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
90 |
createdby INT4 REFERENCES login (loginid) NOT NULL, |
91 |
epoch TIMESTAMP NOT NULL, |
|
935
by wagrant
userdb: Large changes: |
92 |
UNIQUE (projectsetid, groupnm) |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
93 |
);
|
94 |
||
935
by wagrant
userdb: Large changes: |
95 |
CREATE OR REPLACE FUNCTION check_group_namespacing_insertupdate() |
96 |
RETURNS trigger AS ' |
|
97 |
DECLARE
|
|
98 |
oid INTEGER;
|
|
99 |
BEGIN
|
|
100 |
SELECT offeringid INTO oid FROM project_set WHERE project_set.projectsetid = NEW.projectsetid;
|
|
1044
by wagrant
userdb: Properly verify that the group name is unique only within the |
101 |
PERFORM 1 FROM project_group, project_set WHERE project_set.offeringid = oid AND project_group.projectsetid = project_set.projectsetid AND project_group.groupnm = NEW.groupnm;
|
935
by wagrant
userdb: Large changes: |
102 |
IF found THEN
|
103 |
RAISE EXCEPTION ''a project group named % already exists in offering ID %'', NEW.groupnm, oid;
|
|
104 |
END IF;
|
|
105 |
RETURN NEW;
|
|
106 |
END;
|
|
107 |
' LANGUAGE 'plpgsql'; |
|
108 |
||
109 |
CREATE TRIGGER check_group_namespacing |
|
110 |
BEFORE INSERT OR UPDATE ON project_group |
|
111 |
FOR EACH ROW EXECUTE PROCEDURE check_group_namespacing_insertupdate(); |
|
112 |
||
353
by drtomc
Start addressing sb's suggestions. |
113 |
CREATE TABLE group_invitation ( |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
114 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
115 |
groupid INT4 REFERENCES project_group (groupid) NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
116 |
inviter INT4 REFERENCES login (loginid) NOT NULL, |
117 |
invited TIMESTAMP NOT NULL, |
|
118 |
accepted TIMESTAMP, |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
119 |
UNIQUE (loginid,groupid) |
25
by drtomc
A bit more work on the userdb stuff. |
120 |
);
|
121 |
||
353
by drtomc
Start addressing sb's suggestions. |
122 |
CREATE TABLE group_member ( |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
123 |
loginid INT4 REFERENCES login (loginid), |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
124 |
groupid INT4 REFERENCES project_group (groupid), |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
125 |
PRIMARY KEY (loginid,groupid) |
25
by drtomc
A bit more work on the userdb stuff. |
126 |
);
|
127 |
||
128 |
CREATE TABLE enrolment ( |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
129 |
loginid INT4 REFERENCES login (loginid), |
353
by drtomc
Start addressing sb's suggestions. |
130 |
offeringid INT4 REFERENCES offering (offeringid), |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
131 |
result INT, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
132 |
special_result VARCHAR, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
133 |
supp_result INT, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
134 |
special_supp_result VARCHAR, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
135 |
notes VARCHAR, |
935
by wagrant
userdb: Large changes: |
136 |
active BOOL NOT NULL DEFAULT true, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
137 |
PRIMARY KEY (loginid,offeringid) |
25
by drtomc
A bit more work on the userdb stuff. |
138 |
);
|
139 |
||
935
by wagrant
userdb: Large changes: |
140 |
CREATE OR REPLACE FUNCTION confirm_active_semester_insertupdate() |
141 |
RETURNS trigger AS ' |
|
142 |
DECLARE
|
|
143 |
active BOOL;
|
|
144 |
BEGIN
|
|
145 |
SELECT semester.active INTO active FROM offering, semester WHERE offeringid=NEW.offeringid AND semester.semesterid = offering.semesterid;
|
|
146 |
IF NOT active AND NEW.active = true THEN
|
|
147 |
RAISE EXCEPTION ''cannot have active enrolment for % in offering %, as the semester is inactive'', NEW.loginid, NEW.offeringid;
|
|
148 |
END IF;
|
|
149 |
RETURN NEW;
|
|
150 |
END;
|
|
151 |
' LANGUAGE 'plpgsql'; |
|
152 |
||
153 |
CREATE TRIGGER confirm_active_semester |
|
154 |
BEFORE INSERT OR UPDATE ON enrolment |
|
155 |
FOR EACH ROW EXECUTE PROCEDURE confirm_active_semester_insertupdate(); |
|
156 |
||
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
157 |
CREATE TABLE assessed ( |
158 |
assessedid SERIAL PRIMARY KEY NOT NULL, |
|
159 |
loginid INT4 REFERENCES login (loginid), |
|
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
160 |
groupid INT4 REFERENCES project_group (groupid), |
915
by mattgiuca
Moved projectid from all tables using assessedid into the assessed table |
161 |
projectid INT4 REFERENCES project (projectid) NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
162 |
-- exactly one of loginid and groupid must be non-null
|
163 |
CHECK ((loginid IS NOT NULL AND groupid IS NULL) |
|
164 |
OR (loginid IS NULL AND groupid IS NOT NULL)) |
|
165 |
);
|
|
166 |
||
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
167 |
CREATE TABLE project_extension ( |
391
by drtomc
Fix a couple of typos. |
168 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
169 |
deadline TIMESTAMP NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
170 |
approver INT4 REFERENCES login (loginid) NOT NULL, |
171 |
notes VARCHAR |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
172 |
);
|
173 |
||
665
by drtomc
userdb: Add a submission table, as per our discussions. |
174 |
CREATE TABLE project_submission ( |
175 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
|
176 |
path VARCHAR NOT NULL, |
|
177 |
revision INT4 NOT NULL |
|
178 |
);
|
|
179 |
||
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
180 |
CREATE TABLE project_mark ( |
391
by drtomc
Fix a couple of typos. |
181 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
182 |
componentid INT4, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
183 |
marker INT4 REFERENCES login (loginid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
184 |
mark INT, |
185 |
marked TIMESTAMP, |
|
186 |
feedback VARCHAR, |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
187 |
notes VARCHAR |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
188 |
);
|
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
189 |
|
935
by wagrant
userdb: Large changes: |
190 |
-- Worksheets
|
191 |
-- ----------
|
|
192 |
||
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
193 |
CREATE TABLE problem ( |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
194 |
problemid SERIAL PRIMARY KEY NOT NULL, |
659
by drtomc
Add a little script for stuffing exercises into the database. |
195 |
identifier VARCHAR UNIQUE NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
196 |
spec VARCHAR |
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
197 |
);
|
198 |
||
725
by mattgiuca
The database now stores a cache of all the worksheets and what problems |
199 |
CREATE TABLE worksheet ( |
200 |
worksheetid SERIAL PRIMARY KEY NOT NULL, |
|
201 |
subject VARCHAR NOT NULL, |
|
202 |
identifier VARCHAR NOT NULL, |
|
203 |
assessable BOOLEAN, |
|
204 |
mtime TIMESTAMP, |
|
205 |
UNIQUE (subject, identifier) |
|
206 |
);
|
|
207 |
||
208 |
CREATE TABLE worksheet_problem ( |
|
209 |
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL, |
|
210 |
problemid INT4 REFERENCES problem (problemid) NOT NULL, |
|
211 |
optional BOOLEAN, |
|
212 |
PRIMARY KEY (worksheetid, problemid) |
|
213 |
);
|
|
214 |
||
353
by drtomc
Start addressing sb's suggestions. |
215 |
CREATE TABLE problem_tag ( |
392
by drtomc
Fix another glitch. |
216 |
problemid INT4 REFERENCES problem (problemid), |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
217 |
tag VARCHAR NOT NULL, |
366
by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are. |
218 |
description VARCHAR, |
219 |
standard BOOLEAN NOT NULL, |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
220 |
added_by INT4 REFERENCES login (loginid) NOT NULL, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
221 |
date TIMESTAMP NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
222 |
PRIMARY KEY (problemid,added_by,tag) |
223 |
);
|
|
224 |
||
225 |
CREATE TABLE problem_test_case ( |
|
226 |
problemid INT4 REFERENCES problem (problemid) NOT NULL, |
|
227 |
testcaseid SERIAL UNIQUE NOT NULL, |
|
228 |
testcase VARCHAR, |
|
229 |
description VARCHAR, |
|
230 |
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private')) |
|
231 |
);
|
|
232 |
||
353
by drtomc
Start addressing sb's suggestions. |
233 |
CREATE TABLE problem_test_case_tag ( |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
234 |
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL, |
235 |
tag VARCHAR NOT NULL, |
|
236 |
description VARCHAR, |
|
366
by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are. |
237 |
standard BOOLEAN NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
238 |
added_by INT4 REFERENCES login (loginid) NOT NULL, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
239 |
date TIMESTAMP NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
240 |
PRIMARY KEY (testcaseid,added_by,tag) |
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
241 |
);
|
242 |
||
243 |
CREATE TABLE problem_attempt ( |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
244 |
problemid INT4 REFERENCES problem (problemid) NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
245 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
246 |
date TIMESTAMP NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
247 |
attempt VARCHAR NOT NULL, |
248 |
complete BOOLEAN NOT NULL, |
|
1021
by dcoles
Database: Adds active column to problem_attempt table. |
249 |
active BOOLEAN NOT NULL DEFAULT true, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
250 |
PRIMARY KEY (problemid,loginid,date) |
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
251 |
);
|
252 |
||
697
by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are |
253 |
CREATE TABLE problem_save ( |
254 |
problemid INT4 REFERENCES problem (problemid) NOT NULL, |
|
255 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
|
256 |
date TIMESTAMP NOT NULL, |
|
257 |
text VARCHAR NOT NULL, |
|
258 |
PRIMARY KEY (problemid,loginid) |
|
259 |
);
|
|
260 |
||
324
by drtomc
Should all be okay now. |
261 |
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid); |
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
262 |
|
263 |
CREATE TABLE problem_attempt_breakdown ( |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
264 |
problemid INT4 REFERENCES problem (problemid) NOT NULL, |
265 |
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL, |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
266 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
267 |
date TIMESTAMP NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
268 |
result BOOLEAN |
269 |
);
|
|
270 |
||
353
by drtomc
Start addressing sb's suggestions. |
271 |
CREATE TABLE problem_prerequisite ( |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
272 |
parent INT4 REFERENCES problem (problemid) NOT NULL, |
273 |
child INT4 REFERENCES problem (problemid) NOT NULL, |
|
274 |
PRIMARY KEY (parent,child) |
|
275 |
);
|
|
276 |