1099.1.142
by Nick Chadwick
Fixed a slight issue with the migration and the users.sql files not |
1 |
BEGIN; |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
2 |
DO NOT APPLY THIS MIGRATION WITHOUT READING THE FOLLOWING; |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
3 |
-- This migration will delete all problem attempts and saves.
|
4 |
-- The new database schema links attempts and saves to specific worksheets.
|
|
5 |
-- Worksheets are linked to specific offerings.
|
|
6 |
-- Problems are no longer referenced by and id number, instead they are
|
|
7 |
-- referenced by an identifier TEXT field.
|
|
8 |
-- This means that in order to save your current data, you must link its
|
|
9 |
-- worksheet to an offering, and link the attempt to a problem identifier.
|
|
10 |
-- TODO: Write a script to save the problem attempts somehow.
|
|
11 |
||
12 |
-- Move the exercises from being stored as flat files, to being stored in
|
|
13 |
-- The Database
|
|
14 |
-- Drop Old, Unused tables.
|
|
15 |
DROP TABLE problem_attempt_breakdown; |
|
16 |
DROP TABLE problem_test_case_tag; |
|
17 |
DROP TABLE problem_tag; |
|
18 |
DROP TABLE problem_test_case; |
|
19 |
DROP TABLE problem_prerequisite; |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
20 |
DROP TABLE problem_save; |
21 |
DROP TABLE problem_attempt; |
|
22 |
DROP TABLE worksheet_problem; |
|
23 |
DROP TABLE problem; |
|
24 |
DROP TABLE worksheet; |
|
25 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
26 |
CREATE TABLE exercise ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
27 |
identifier TEXT PRIMARY KEY, |
28 |
name TEXT, |
|
29 |
description TEXT, |
|
30 |
partial TEXT, |
|
31 |
solution TEXT, |
|
32 |
include TEXT, |
|
33 |
num_rows INT4 |
|
34 |
);
|
|
35 |
||
36 |
CREATE TABLE worksheet ( |
|
37 |
worksheetid SERIAL PRIMARY KEY, |
|
38 |
offeringid INT4 REFERENCES offering (offeringid) NOT NULL, |
|
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
39 |
identifier TEXT NOT NULL, |
1099.4.1
by Nick Chadwick
Working on putting worksheets into the database. |
40 |
name TEXT NOT NULL, |
1099.4.3
by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets |
41 |
data TEXT NOT NULL, |
42 |
assessable BOOLEAN NOT NULL, |
|
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
43 |
seq_no INT4 NOT NULL, |
1099.1.180
by Nick Chadwick
This commit changes the tutorial service, which now almost exclusively |
44 |
format TEXT NOT NUll, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
45 |
UNIQUE (offeringid, identifier) |
46 |
);
|
|
47 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
48 |
CREATE TABLE worksheet_exercise ( |
49 |
ws_ex_id SERIAL PRIMARY KEY, |
|
1099.4.3
by Nick Chadwick
Updated the tutorial service, to now allow users to edit worksheets |
50 |
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
51 |
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL, |
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
52 |
seq_no INT4 NOT NULL, |
53 |
active BOOLEAN NOT NULL DEFAULT true, |
|
54 |
optional BOOLEAN NOT NULL, |
|
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
55 |
UNIQUE (worksheetid, exerciseid) |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
56 |
);
|
57 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
58 |
CREATE TABLE exercise_attempt ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
59 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
60 |
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
61 |
date TIMESTAMP NOT NULL, |
1099.1.185
by William Grant
A few almost-final worksheet/exercise schema changes. Mainly cosmetic. |
62 |
attempt TEXT NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
63 |
complete BOOLEAN NOT NULL, |
64 |
active BOOLEAN NOT NULL DEFAULT true, |
|
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
65 |
PRIMARY KEY (loginid, ws_ex_id, date) |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
66 |
);
|
67 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
68 |
CREATE TABLE exercise_save ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
69 |
loginid INT4 REFERENCES login (loginid) NOT NULL, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
70 |
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
71 |
date TIMESTAMP NOT NULL, |
72 |
text TEXT NOT NULL, |
|
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
73 |
PRIMARY KEY (loginid, ws_ex_id) |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
74 |
);
|
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
75 |
|
76 |
CREATE TABLE test_suite ( |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
77 |
suiteid SERIAL PRIMARY KEY, |
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
78 |
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
79 |
description TEXT, |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
80 |
seq_no INT4, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
81 |
function TEXT, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
82 |
stdin TEXT |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
83 |
);
|
84 |
||
85 |
CREATE TABLE test_case ( |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
86 |
testid SERIAL PRIMARY KEY, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
87 |
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL, |
88 |
passmsg TEXT, |
|
89 |
failmsg TEXT, |
|
90 |
test_default TEXT, |
|
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
91 |
seq_no INT4 |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
92 |
);
|
93 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
94 |
CREATE TABLE suite_variable ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
95 |
varid SERIAL PRIMARY KEY, |
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
96 |
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. |
97 |
var_name TEXT, |
98 |
var_value TEXT, |
|
99 |
var_type TEXT NOT NULL, |
|
100 |
arg_no INT4 |
|
101 |
);
|
|
102 |
||
1099.1.195
by William Grant
Rename problem to exercise in the DB. |
103 |
CREATE TABLE test_case_part ( |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
104 |
partid SERIAL PRIMARY KEY, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
105 |
testid INT4 REFERENCES test_case (testid) NOT NULL, |
1099.1.145
by Nick Chadwick
Minor updates to the sql for the userdb |
106 |
part_type TEXT NOT NULL, |
1099.1.141
by Nick Chadwick
Updated the exercises to be loaded from the database, not a local file. |
107 |
test_type TEXT, |
108 |
data TEXT, |
|
109 |
filename TEXT |
|
1099.1.114
by Nick Chadwick
Modified the database so that exercises are now stored in the database, rather |
110 |
);
|
111 |
||
112 |
COMMIT; |