~azzar1/unity/add-show-desktop-key

1099.1.142 by Nick Chadwick
Fixed a slight issue with the migration and the users.sql files not
1
BEGIN;
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
2
3
-- Check that the provided name is sane for use in URLs.
4
CREATE OR REPLACE FUNCTION valid_url_name(name text) RETURNS boolean AS 
5
$$
6
    BEGIN
1606.1.15 by William Grant
Permit underscores in all names.
7
        RETURN name ~ E'^[a-z0-9][a-z0-9_\+\.\-]*$';
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
8
    END;
9
$$ LANGUAGE 'plpgsql';
10
11
-- Just like valid_url_name, except that @ is permitted (so we can use a
12
-- reasonable subset of email addresses as usernames).
13
CREATE OR REPLACE FUNCTION valid_login_name(name text) RETURNS boolean AS 
14
$$
15
    BEGIN
1606.1.15 by William Grant
Permit underscores in all names.
16
        RETURN name ~ E'^[a-z0-9][a-z0-9@_\+\.\-]*$';
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
17
    END;
18
$$ LANGUAGE 'plpgsql';
19
936 by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was
20
CREATE SEQUENCE login_unixid_seq MINVALUE 1000 MAXVALUE 29999 START WITH 5000;
21
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
22
CREATE TABLE login (
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
23
    loginid     SERIAL PRIMARY KEY NOT NULL,
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
24
    login       VARCHAR UNIQUE NOT NULL CHECK (valid_login_name(login)),
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
25
    passhash    VARCHAR,
475 by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to
26
    state	VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending',
1080.1.69 by William Grant
userdb: login.state now defaults to 'no_agreement'.
27
                                              'enabled', 'disabled'))
28
                                 DEFAULT 'no_agreement',
1112 by matt.giuca
userdb/users.sql: Fixed two syntax errors. Jeepers!
29
    admin       BOOLEAN NOT NULL DEFAULT false,
936 by wagrant
userdb: Add the changes from migration 20080718-01 to users.sql. It was
30
    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
31
    nick        VARCHAR NOT NULL,
32
    pass_exp    TIMESTAMP,
33
    acct_exp    TIMESTAMP,
34
    last_login  TIMESTAMP,
522 by drtomc
Add quite a lot of stuff to get usrmgt happening.
35
    svn_pass    VARCHAR,
462 by mattgiuca
userdb/users.sql: Added email field to login.
36
    email       VARCHAR,
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
37
    fullname    VARCHAR NOT NULL,
631 by mattgiuca
users.sql: Added "settings" field to the login table.
38
    studentid   VARCHAR, -- may be null
39
    settings    VARCHAR
25 by drtomc
A bit more work on the userdb stuff.
40
);
41
935 by wagrant
userdb: Large changes:
42
-- Subjects
43
-- --------
44
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
45
CREATE TABLE subject (
46
    subjectid       SERIAL PRIMARY KEY NOT NULL,
47
    subj_code       VARCHAR UNIQUE NOT NULL,
48
    subj_name       VARCHAR NOT NULL,
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
49
    subj_short_name VARCHAR UNIQUE NOT NULL CHECK (valid_url_name(subj_short_name))
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
50
);
51
935 by wagrant
userdb: Large changes:
52
CREATE TABLE semester (
53
    semesterid  SERIAL PRIMARY KEY NOT NULL,
1822 by Matt Giuca
Changed database schema 'semester' table. 'year' and 'semester' fields now allow any length, not just 4 or 1 respectively. (LP: #610330).
54
    year        TEXT NOT NULL CHECK (valid_url_name(year)),
1822.1.2 by William Grant
Update schema, add missing UNIQUE constraint, and update sample data.
55
    url_name    TEXT NOT NULL CHECK (valid_url_name(url_name)),
56
    code        TEXT NOT NULL,
57
    display_name TEXT NOT NULL,
1112 by matt.giuca
userdb/users.sql: Fixed two syntax errors. Jeepers!
58
    state       TEXT NOT NULL CHECK (state IN ('disabled', 'past',
59
                                    'current', 'future')) DEFAULT 'current',
1822.1.2 by William Grant
Update schema, add missing UNIQUE constraint, and update sample data.
60
    UNIQUE (year, url_name),
61
    UNIQUE (year, code)
935 by wagrant
userdb: Large changes:
62
);
63
353 by drtomc
Start addressing sb's suggestions.
64
CREATE TABLE offering (
324 by drtomc
Should all be okay now.
65
    offeringid  SERIAL PRIMARY KEY NOT NULL,
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
66
    subject     INT4 REFERENCES subject (subjectid) NOT NULL,
935 by wagrant
userdb: Large changes:
67
    semesterid  INTEGER REFERENCES semester (semesterid) NOT NULL,
1451.1.2 by William Grant
Move Subject.url to Offering, and add Offering.description. Show these on the offering index.
68
    description VARCHAR,
69
    url         VARCHAR,
1695.1.1 by William Grant
Add DB patch for mark showing, and worksheet cutoff and publishing.
70
    show_worksheet_marks BOOLEAN NOT NULL DEFAULT false,
71
    worksheet_cutoff TIMESTAMP,
935 by wagrant
userdb: Large changes:
72
    groups_student_permissions  VARCHAR NOT NULL DEFAULT 'none',
73
    CHECK (groups_student_permissions in ('none', 'invite', 'create')),
74
    UNIQUE (subject, semesterid)
75
);
76
77
-- Projects and groups
78
-- -------------------
79
80
CREATE TABLE project_set (
81
    projectsetid  SERIAL PRIMARY KEY NOT NULL,
82
    offeringid    INTEGER REFERENCES offering (offeringid) NOT NULL,
1165.1.45 by William Grant
Remove the NOT NULL and default from project_set.max_students_per_group.
83
    max_students_per_group  INTEGER
324 by drtomc
Should all be okay now.
84
);
85
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
86
CREATE TABLE project (
87
    projectid   SERIAL PRIMARY KEY NOT NULL,
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
88
    short_name  TEXT NOT NULL CHECK (valid_url_name(short_name)),
1165.1.3 by William Grant
Add NOT NULL name and short_name columns to project.
89
    name        TEXT NOT NULL,
90
    synopsis    TEXT,
91
    url         TEXT,
935 by wagrant
userdb: Large changes:
92
    projectsetid  INTEGER REFERENCES project_set (projectsetid) NOT NULL,
1316.1.1 by David Coles
Set project.deadline to NOT NULL since it is required for submits.
93
    deadline    TIMESTAMP NOT NULL
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
94
);
95
1165.1.3 by William Grant
Add NOT NULL name and short_name columns to project.
96
CREATE OR REPLACE FUNCTION check_project_namespacing_insertupdate()
97
RETURNS trigger AS '
98
    DECLARE
99
        oid INTEGER;
100
    BEGIN
101
        IF TG_OP = ''UPDATE'' THEN
102
            IF NEW.projectsetid = OLD.projectsetid AND NEW.short_name = OLD.short_name THEN
103
                RETURN NEW;
104
            END IF;
105
        END IF;
106
        SELECT offeringid INTO oid FROM project_set WHERE project_set.projectsetid = NEW.projectsetid;
107
        PERFORM 1 FROM project, project_set
108
        WHERE project_set.offeringid = oid AND
109
              project.projectsetid = project_set.projectsetid AND
110
              project.short_name = NEW.short_name;
111
        IF found THEN
112
            RAISE EXCEPTION ''a project named % already exists in offering ID %'', NEW.short_name, oid;
113
        END IF;
114
        RETURN NEW;
115
    END;
116
' LANGUAGE 'plpgsql';
117
118
CREATE TRIGGER check_project_namespacing
119
    BEFORE INSERT OR UPDATE ON project
120
    FOR EACH ROW EXECUTE PROCEDURE check_project_namespacing_insertupdate();
121
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
122
CREATE TABLE project_group (
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
123
    groupnm     VARCHAR NOT NULL CHECK (valid_url_name(groupnm)),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
124
    groupid     SERIAL PRIMARY KEY NOT NULL,
935 by wagrant
userdb: Large changes:
125
    projectsetid  INTEGER REFERENCES project_set (projectsetid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
126
    nick        VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
127
    createdby   INT4 REFERENCES login (loginid) NOT NULL,
128
    epoch       TIMESTAMP NOT NULL,
935 by wagrant
userdb: Large changes:
129
    UNIQUE (projectsetid, groupnm)
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
130
);
131
935 by wagrant
userdb: Large changes:
132
CREATE OR REPLACE FUNCTION check_group_namespacing_insertupdate()
133
RETURNS trigger AS '
134
    DECLARE
135
        oid INTEGER;
136
    BEGIN
137
        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
138
        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:
139
        IF found THEN
140
            RAISE EXCEPTION ''a project group named % already exists in offering ID %'', NEW.groupnm, oid;
141
        END IF;
142
        RETURN NEW;
143
    END;
144
' LANGUAGE 'plpgsql';
145
146
CREATE TRIGGER check_group_namespacing
147
    BEFORE INSERT OR UPDATE ON project_group
148
    FOR EACH ROW EXECUTE PROCEDURE check_group_namespacing_insertupdate();
149
353 by drtomc
Start addressing sb's suggestions.
150
CREATE TABLE group_invitation (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
151
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
152
    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. :-)
153
    inviter     INT4 REFERENCES login (loginid) NOT NULL,
154
    invited     TIMESTAMP NOT NULL,
155
    accepted    TIMESTAMP,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
156
    UNIQUE (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
157
);
158
353 by drtomc
Start addressing sb's suggestions.
159
CREATE TABLE group_member (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
160
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
161
    groupid     INT4 REFERENCES project_group (groupid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
162
    PRIMARY KEY (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
163
);
164
165
CREATE TABLE enrolment (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
166
    loginid     INT4 REFERENCES login (loginid),
353 by drtomc
Start addressing sb's suggestions.
167
    offeringid  INT4 REFERENCES offering (offeringid),
1101 by William Grant
Privileges (apart from admin) are now offering-local, not global.
168
    role        TEXT NOT NULL CHECK (role IN ('student', 'tutor',
169
                                              'lecturer')) DEFAULT 'student',
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
170
    result      INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
171
    special_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
172
    supp_result INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
173
    special_supp_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
174
    notes       VARCHAR,
935 by wagrant
userdb: Large changes:
175
    active      BOOL NOT NULL DEFAULT true,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
176
    PRIMARY KEY (loginid,offeringid)
25 by drtomc
A bit more work on the userdb stuff.
177
);
178
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
179
CREATE TABLE assessed (
180
    assessedid  SERIAL PRIMARY KEY NOT NULL,
181
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
182
    groupid     INT4 REFERENCES project_group (groupid),
915 by mattgiuca
Moved projectid from all tables using assessedid into the assessed table
183
    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. :-)
184
    -- exactly one of loginid and groupid must be non-null
185
    CHECK ((loginid IS NOT NULL AND groupid IS NULL)
186
        OR (loginid IS NULL AND groupid IS NOT NULL))
187
);
188
1790 by William Grant
Add unique indices on assessed(loginid, projectid) and assessed(groupid, projectid), where they should have been from the start.
189
-- We must use conditional constraints here -- NULL != NULL.
190
CREATE UNIQUE INDEX assessed_loginid_key ON assessed(loginid, projectid) WHERE loginid IS NOT NULL;
191
CREATE UNIQUE INDEX assessed_groupid_key ON assessed(groupid, projectid) WHERE groupid IS NOT NULL;
192
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
193
CREATE TABLE project_extension (
1165.1.2 by William Grant
Add serial primary keys to project_{extension,submission}.
194
    extensionid SERIAL PRIMARY KEY,
391 by drtomc
Fix a couple of typos.
195
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
1818.1.1 by Matt Giuca
Database: Modified project_extension table; replaced 'deadline TIMESTAMP' with 'days INT'. This means the extension is a time delta on top of the existing deadline, not a replacement deadline.
196
    days        INT NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
197
    approver    INT4 REFERENCES login (loginid) NOT NULL,
198
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
199
);
200
665 by drtomc
userdb: Add a submission table, as per our discussions.
201
CREATE TABLE project_submission (
1165.1.2 by William Grant
Add serial primary keys to project_{extension,submission}.
202
    submissionid SERIAL PRIMARY KEY,
665 by drtomc
userdb: Add a submission table, as per our discussions.
203
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
204
    path        VARCHAR NOT NULL,
1165.1.1 by Matt Giuca
users.sql: Added to project_submission: 'date_submitted'.
205
    revision    INT4 NOT NULL,
1165.1.42 by William Grant
Record who submitted each submission.
206
    date_submitted TIMESTAMP NOT NULL,
207
    submitter   INT4 REFERENCES login (loginid) NOT NULL
665 by drtomc
userdb: Add a submission table, as per our discussions.
208
);
209
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
210
CREATE TABLE project_mark (
391 by drtomc
Fix a couple of typos.
211
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
212
    componentid INT4,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
213
    marker      INT4 REFERENCES login (loginid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
214
    mark        INT,
215
    marked      TIMESTAMP,
216
    feedback    VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
217
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
218
);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
219
935 by wagrant
userdb: Large changes:
220
-- Worksheets
221
-- ----------
1099.1.195 by William Grant
Rename problem to exercise in the DB.
222
CREATE TABLE exercise (
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
223
    identifier  TEXT PRIMARY KEY CHECK (valid_url_name(identifier)),
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
224
    name        TEXT,
225
    description TEXT,
1720.1.4 by William Grant
Cache exercise and worksheet rST->XHTML conversions in the DB.
226
    description_xhtml_cache TEXT,
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
227
    partial     TEXT,
228
    solution    TEXT,
229
    include     TEXT,
230
    num_rows    INT4
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
231
);
232
725 by mattgiuca
The database now stores a cache of all the worksheets and what problems
233
CREATE TABLE worksheet (
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
234
    worksheetid SERIAL PRIMARY KEY,
235
    offeringid  INT4 REFERENCES offering (offeringid) NOT NULL,
1606.1.1 by William Grant
Add DB constraints for names used in URLs.
236
    identifier  TEXT NOT NULL CHECK (valid_url_name(identifier)),
1099.4.1 by Nick Chadwick
Working on putting worksheets into the database.
237
    name        TEXT NOT NULL,
1099.4.3 by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets
238
    data        TEXT NOT NULL,
1720.1.4 by William Grant
Cache exercise and worksheet rST->XHTML conversions in the DB.
239
    data_xhtml_cache TEXT,
1099.4.3 by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets
240
    assessable  BOOLEAN NOT NULL,
1695.1.1 by William Grant
Add DB patch for mark showing, and worksheet cutoff and publishing.
241
    published   BOOLEAN NOT NULL DEFAULT true,
1099.1.184 by William Grant
Fix a column name mismatch between the migration and primary schema.
242
    seq_no      INT4 NOT NULL,
1099.4.3 by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets
243
    format      TEXT NOT NUll,
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
244
    UNIQUE (offeringid, identifier)
725 by mattgiuca
The database now stores a cache of all the worksheets and what problems
245
);
246
1099.1.195 by William Grant
Rename problem to exercise in the DB.
247
CREATE TABLE worksheet_exercise (
248
    ws_ex_id        SERIAL PRIMARY KEY,
1099.4.3 by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets
249
    worksheetid     INT4 REFERENCES worksheet (worksheetid) NOT NULL,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
250
    exerciseid      TEXT REFERENCES exercise (identifier) NOT NULL,
1099.1.185 by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic.
251
    seq_no          INT4 NOT NULL,
252
    active          BOOLEAN NOT NULL DEFAULT true,
253
    optional        BOOLEAN NOT NULL,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
254
    UNIQUE (worksheetid, exerciseid)
725 by mattgiuca
The database now stores a cache of all the worksheets and what problems
255
);
256
1099.1.195 by William Grant
Rename problem to exercise in the DB.
257
CREATE TABLE exercise_attempt (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
258
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
259
    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.
260
    date        TIMESTAMP NOT NULL,
1099.1.185 by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic.
261
    attempt     TEXT NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
262
    complete    BOOLEAN NOT NULL,
1021 by dcoles
Database: Adds active column to problem_attempt table.
263
    active      BOOLEAN NOT NULL DEFAULT true,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
264
    PRIMARY KEY (loginid, ws_ex_id, date)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
265
);
266
1099.1.195 by William Grant
Rename problem to exercise in the DB.
267
CREATE TABLE exercise_save (
697 by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are
268
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
269
    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
270
    date        TIMESTAMP NOT NULL,
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
271
    text        TEXT NOT NULL,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
272
    PRIMARY KEY (loginid, ws_ex_id)
697 by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are
273
);
274
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
275
CREATE TABLE test_suite (
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
276
    suiteid     SERIAL PRIMARY KEY,
1099.1.195 by William Grant
Rename problem to exercise in the DB.
277
    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
278
    description TEXT,
279
    seq_no      INT4,
1099.1.141 by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file.
280
    function    TEXT,
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
281
    stdin       TEXT
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
282
);
283
284
CREATE TABLE test_case (
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
285
    testid          SERIAL PRIMARY KEY,
1099.1.141 by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file.
286
    suiteid         INT4 REFERENCES test_suite (suiteid) NOT NULL,
287
    passmsg         TEXT,
288
    failmsg         TEXT,
289
    test_default    TEXT,
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
290
    seq_no          INT4
1099.1.141 by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file.
291
);
292
1099.1.195 by William Grant
Rename problem to exercise in the DB.
293
CREATE TABLE suite_variable (
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
294
    varid       SERIAL PRIMARY KEY,
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
295
    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.
296
    var_name    TEXT,
297
    var_value   TEXT,
298
    var_type    TEXT NOT NULL,
299
    arg_no      INT4
300
);
301
1099.1.195 by William Grant
Rename problem to exercise in the DB.
302
CREATE TABLE test_case_part (
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
303
    partid          SERIAL PRIMARY KEY,
1099.1.141 by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file.
304
    testid          INT4 REFERENCES test_case (testid) NOT NULL,
1099.1.145 by Nick Chadwick
Minor updates to the sql for the userdb
305
    part_type       TEXT NOT NULL,
1099.1.141 by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file.
306
    test_type       TEXT,
307
    data            TEXT,
308
    filename        TEXT
1099.1.114 by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather
309
);
1099.1.142 by Nick Chadwick
Fixed a slight issue with the migration and the users.sql files not
310
COMMIT;