1099.1.142
by Nick Chadwick
Fixed a slight issue with the migration and the users.sql files not |
1 |
BEGIN; |
936
by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was |
2 |
CREATE SEQUENCE login_unixid_seq MINVALUE 1000 MAXVALUE 29999 START WITH 5000; |
3 |
||
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
4 |
CREATE TABLE login ( |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
5 |
loginid SERIAL PRIMARY KEY NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
6 |
login VARCHAR UNIQUE NOT NULL, |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
7 |
passhash VARCHAR, |
475
by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to |
8 |
state VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending', |
1080.1.69
by William Grant
userdb: login.state now defaults to 'no_agreement'. |
9 |
'enabled', 'disabled')) |
10 |
DEFAULT 'no_agreement', |
|
1112
by matt.giuca
userdb/users.sql: Fixed two syntax errors. Jeepers! |
11 |
admin BOOLEAN NOT NULL DEFAULT false, |
936
by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was |
12 |
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 |
13 |
nick VARCHAR NOT NULL, |
14 |
pass_exp TIMESTAMP, |
|
15 |
acct_exp TIMESTAMP, |
|
16 |
last_login TIMESTAMP, |
|
522
by drtomc
Add quite a lot of stuff to get usrmgt happening. |
17 |
svn_pass VARCHAR, |
462
by mattgiuca
userdb/users.sql: Added email field to login. |
18 |
email VARCHAR, |
446
by drtomc
users.sql: constrain the rolenm to be from a given set of roles. |
19 |
fullname VARCHAR NOT NULL, |
631
by mattgiuca
users.sql: Added "settings" field to the login table. |
20 |
studentid VARCHAR, -- may be null |
21 |
settings VARCHAR |
|
25
by drtomc
A bit more work on the userdb stuff. |
22 |
);
|
23 |
||
935
by wagrant
userdb: Large changes: |
24 |
-- Subjects
|
25 |
-- --------
|
|
26 |
||
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
27 |
CREATE TABLE subject ( |
28 |
subjectid SERIAL PRIMARY KEY NOT NULL, |
|
29 |
subj_code VARCHAR UNIQUE NOT NULL, |
|
30 |
subj_name VARCHAR NOT NULL, |
|
916
by mattgiuca
userdb: Added constraints UNIQUE and NOT NULL to subjects.subj_short_name. |
31 |
subj_short_name VARCHAR UNIQUE NOT NULL, |
817
by mattgiuca
users.sql: Moved url from offering to subjects table. |
32 |
url VARCHAR |
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
33 |
);
|
34 |
||
935
by wagrant
userdb: Large changes: |
35 |
CREATE TABLE semester ( |
36 |
semesterid SERIAL PRIMARY KEY NOT NULL, |
|
37 |
year CHAR(4) NOT NULL, |
|
38 |
semester CHAR(1) NOT NULL, |
|
1112
by matt.giuca
userdb/users.sql: Fixed two syntax errors. Jeepers! |
39 |
state TEXT NOT NULL CHECK (state IN ('disabled', 'past', |
40 |
'current', 'future')) DEFAULT 'current', |
|
935
by wagrant
userdb: Large changes: |
41 |
UNIQUE (year, semester) |
42 |
);
|
|
43 |
||
353
by drtomc
Start addressing sb's suggestions. |
44 |
CREATE TABLE offering ( |
324
by drtomc
Should all be okay now. |
45 |
offeringid SERIAL PRIMARY KEY NOT NULL, |
816
by mattgiuca
users.sql: Updated database schema; split subject and offering tables. |
46 |
subject INT4 REFERENCES subject (subjectid) NOT NULL, |
935
by wagrant
userdb: Large changes: |
47 |
semesterid INTEGER REFERENCES semester (semesterid) NOT NULL, |
48 |
groups_student_permissions VARCHAR NOT NULL DEFAULT 'none', |
|
49 |
CHECK (groups_student_permissions in ('none', 'invite', 'create')), |
|
50 |
UNIQUE (subject, semesterid) |
|
51 |
);
|
|
52 |
||
53 |
-- Projects and groups
|
|
54 |
-- -------------------
|
|
55 |
||
56 |
CREATE TABLE project_set ( |
|
57 |
projectsetid SERIAL PRIMARY KEY NOT NULL, |
|
58 |
offeringid INTEGER REFERENCES offering (offeringid) NOT NULL, |
|
59 |
max_students_per_group INTEGER NOT NULL DEFAULT 4 |
|
324
by drtomc
Should all be okay now. |
60 |
);
|
61 |
||
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
62 |
CREATE TABLE project ( |
63 |
projectid SERIAL PRIMARY KEY NOT NULL, |
|
64 |
synopsis VARCHAR, |
|
65 |
url VARCHAR, |
|
935
by wagrant
userdb: Large changes: |
66 |
projectsetid INTEGER REFERENCES project_set (projectsetid) NOT NULL, |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
67 |
deadline TIMESTAMP |
68 |
);
|
|
69 |
||
70 |
CREATE TABLE project_group ( |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
71 |
groupnm VARCHAR NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
72 |
groupid SERIAL PRIMARY KEY NOT NULL, |
935
by wagrant
userdb: Large changes: |
73 |
projectsetid INTEGER REFERENCES project_set (projectsetid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
74 |
nick VARCHAR, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
75 |
createdby INT4 REFERENCES login (loginid) NOT NULL, |
76 |
epoch TIMESTAMP NOT NULL, |
|
935
by wagrant
userdb: Large changes: |
77 |
UNIQUE (projectsetid, groupnm) |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
78 |
);
|
79 |
||
935
by wagrant
userdb: Large changes: |
80 |
CREATE OR REPLACE FUNCTION check_group_namespacing_insertupdate() |
81 |
RETURNS trigger AS ' |
|
82 |
DECLARE
|
|
83 |
oid INTEGER;
|
|
84 |
BEGIN
|
|
85 |
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 |
86 |
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: |
87 |
IF found THEN
|
88 |
RAISE EXCEPTION ''a project group named % already exists in offering ID %'', NEW.groupnm, oid;
|
|
89 |
END IF;
|
|
90 |
RETURN NEW;
|
|
91 |
END;
|
|
92 |
' LANGUAGE 'plpgsql'; |
|
93 |
||
94 |
CREATE TRIGGER check_group_namespacing |
|
95 |
BEFORE INSERT OR UPDATE ON project_group |
|
96 |
FOR EACH ROW EXECUTE PROCEDURE check_group_namespacing_insertupdate(); |
|
97 |
||
353
by drtomc
Start addressing sb's suggestions. |
98 |
CREATE TABLE group_invitation ( |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
99 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
100 |
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. :-) |
101 |
inviter INT4 REFERENCES login (loginid) NOT NULL, |
102 |
invited TIMESTAMP NOT NULL, |
|
103 |
accepted TIMESTAMP, |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
104 |
UNIQUE (loginid,groupid) |
25
by drtomc
A bit more work on the userdb stuff. |
105 |
);
|
106 |
||
353
by drtomc
Start addressing sb's suggestions. |
107 |
CREATE TABLE group_member ( |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
108 |
loginid INT4 REFERENCES login (loginid), |
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
109 |
groupid INT4 REFERENCES project_group (groupid), |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
110 |
PRIMARY KEY (loginid,groupid) |
25
by drtomc
A bit more work on the userdb stuff. |
111 |
);
|
112 |
||
113 |
CREATE TABLE enrolment ( |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
114 |
loginid INT4 REFERENCES login (loginid), |
353
by drtomc
Start addressing sb's suggestions. |
115 |
offeringid INT4 REFERENCES offering (offeringid), |
1101
by William Grant
Privileges (apart from admin) are now offering-local, not global. |
116 |
role TEXT NOT NULL CHECK (role IN ('student', 'tutor', |
117 |
'lecturer')) DEFAULT 'student', |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
118 |
result INT, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
119 |
special_result VARCHAR, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
120 |
supp_result INT, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
121 |
special_supp_result VARCHAR, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
122 |
notes VARCHAR, |
935
by wagrant
userdb: Large changes: |
123 |
active BOOL NOT NULL DEFAULT true, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
124 |
PRIMARY KEY (loginid,offeringid) |
25
by drtomc
A bit more work on the userdb stuff. |
125 |
);
|
126 |
||
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
127 |
CREATE TABLE assessed ( |
128 |
assessedid SERIAL PRIMARY KEY NOT NULL, |
|
129 |
loginid INT4 REFERENCES login (loginid), |
|
355
by drtomc
Fix a few typos and glitches to actually create the ivle database. |
130 |
groupid INT4 REFERENCES project_group (groupid), |
915
by mattgiuca
Moved projectid from all tables using assessedid into the assessed table |
131 |
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. :-) |
132 |
-- exactly one of loginid and groupid must be non-null
|
133 |
CHECK ((loginid IS NOT NULL AND groupid IS NULL) |
|
134 |
OR (loginid IS NULL AND groupid IS NOT NULL)) |
|
135 |
);
|
|
136 |
||
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
137 |
CREATE TABLE project_extension ( |
391
by drtomc
Fix a couple of typos. |
138 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
139 |
deadline TIMESTAMP NOT NULL, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
140 |
approver INT4 REFERENCES login (loginid) NOT NULL, |
141 |
notes VARCHAR |
|
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
142 |
);
|
143 |
||
665
by drtomc
userdb: Add a submission table, as per our discussions. |
144 |
CREATE TABLE project_submission ( |
145 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
|
146 |
path VARCHAR NOT NULL, |
|
147 |
revision INT4 NOT NULL |
|
148 |
);
|
|
149 |
||
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
150 |
CREATE TABLE project_mark ( |
391
by drtomc
Fix a couple of typos. |
151 |
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
152 |
componentid INT4, |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
153 |
marker INT4 REFERENCES login (loginid) NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
154 |
mark INT, |
155 |
marked TIMESTAMP, |
|
156 |
feedback VARCHAR, |
|
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
157 |
notes VARCHAR |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
158 |
);
|
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
159 |
|
935
by wagrant
userdb: Large changes: |
160 |
-- Worksheets
|
161 |
-- ----------
|
|
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
162 |
CREATE TABLE exercise ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
163 |
identifier TEXT PRIMARY KEY, |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
164 |
name TEXT, |
165 |
description TEXT, |
|
166 |
partial TEXT, |
|
167 |
solution TEXT, |
|
168 |
include TEXT, |
|
169 |
num_rows INT4 |
|
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
170 |
);
|
171 |
||
725
by mattgiuca
The database now stores a cache of all the worksheets and what problems |
172 |
CREATE TABLE worksheet ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
173 |
worksheetid SERIAL PRIMARY KEY, |
174 |
offeringid INT4 REFERENCES offering (offeringid) NOT NULL, |
|
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
175 |
identifier TEXT NOT NULL, |
1099.4.1
by Nick Chadwick
Working on putting worksheets into the database. |
176 |
name TEXT NOT NULL, |
1099.4.3
by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets |
177 |
data TEXT NOT NULL, |
178 |
assessable BOOLEAN NOT NULL, |
|
1099.1.184
by William Grant
Fix a column name mismatch between the migration and primary schema. |
179 |
seq_no INT4 NOT NULL, |
1099.4.3
by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets |
180 |
format TEXT NOT NUll, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
181 |
UNIQUE (offeringid, identifier) |
725
by mattgiuca
The database now stores a cache of all the worksheets and what problems |
182 |
);
|
183 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
184 |
CREATE TABLE worksheet_exercise ( |
185 |
ws_ex_id SERIAL PRIMARY KEY, |
|
1099.4.3
by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets |
186 |
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
187 |
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL, |
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
188 |
seq_no INT4 NOT NULL, |
189 |
active BOOLEAN NOT NULL DEFAULT true, |
|
190 |
optional BOOLEAN NOT NULL, |
|
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
191 |
UNIQUE (worksheetid, exerciseid) |
725
by mattgiuca
The database now stores a cache of all the worksheets and what problems |
192 |
);
|
193 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
194 |
CREATE TABLE exercise_attempt ( |
354
by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-) |
195 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
196 |
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL, |
319
by drtomc
Partial correctness for the user database schema. A few bits and pieces to go. |
197 |
date TIMESTAMP NOT NULL, |
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
198 |
attempt TEXT NOT NULL, |
296
by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb. |
199 |
complete BOOLEAN NOT NULL, |
1021
by dcoles
Database: Adds active column to problem_attempt table. |
200 |
active BOOLEAN NOT NULL DEFAULT true, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
201 |
PRIMARY KEY (loginid, ws_ex_id, date) |
281
by stevenbird
extensive updates based on data modelling discussion with Tom Conway |
202 |
);
|
203 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
204 |
CREATE TABLE exercise_save ( |
697
by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are |
205 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
206 |
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL, |
697
by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are |
207 |
date TIMESTAMP NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
208 |
text TEXT NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
209 |
PRIMARY KEY (loginid, ws_ex_id) |
697
by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are |
210 |
);
|
211 |
||
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
212 |
CREATE TABLE test_suite ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
213 |
suiteid SERIAL PRIMARY KEY, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
214 |
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL, |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
215 |
description TEXT, |
216 |
seq_no INT4, |
|
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
217 |
function TEXT, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
218 |
stdin TEXT |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
219 |
);
|
220 |
||
221 |
CREATE TABLE test_case ( |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
222 |
testid SERIAL PRIMARY KEY, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
223 |
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL, |
224 |
passmsg TEXT, |
|
225 |
failmsg TEXT, |
|
226 |
test_default TEXT, |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
227 |
seq_no INT4 |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
228 |
);
|
229 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
230 |
CREATE TABLE suite_variable ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
231 |
varid SERIAL PRIMARY KEY, |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
232 |
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
233 |
var_name TEXT, |
234 |
var_value TEXT, |
|
235 |
var_type TEXT NOT NULL, |
|
236 |
arg_no INT4 |
|
237 |
);
|
|
238 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
239 |
CREATE TABLE test_case_part ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
240 |
partid SERIAL PRIMARY KEY, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
241 |
testid INT4 REFERENCES test_case (testid) NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
242 |
part_type TEXT NOT NULL, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
243 |
test_type TEXT, |
244 |
data TEXT, |
|
245 |
filename TEXT |
|
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
246 |
);
|
1099.1.142
by Nick Chadwick
Fixed a slight issue with the migration and the users.sql files not |
247 |
COMMIT; |