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

« back to all changes in this revision

Viewing changes to userdb/migrations/20090212-01.sql

  • Committer: William Grant
  • Date: 2009-02-18 00:31:46 UTC
  • mto: (1092.1.63 setup-stuff)
  • mto: This revision was merged to the branch mainline in revision 1100.
  • Revision ID: grantw@unimelb.edu.au-20090218003146-jictayp2dg05ec1d
Remove phpBB3 installation code and instructions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
BEGIN;
 
2
DO NOT APPLY THIS MIGRATION WITHOUT READING THE FOLLOWING;
 
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; 
 
20
DROP TABLE problem_save;
 
21
DROP TABLE problem_attempt;
 
22
DROP TABLE worksheet_problem;
 
23
DROP TABLE problem;
 
24
DROP TABLE worksheet;
 
25
 
 
26
CREATE TABLE problem (
 
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,
 
39
    identifier  VARCHAR NOT NULL,
 
40
    assessable  BOOLEAN,
 
41
    mtime       TIMESTAMP,
 
42
    UNIQUE (offeringid, identifier)
 
43
);
 
44
 
 
45
CREATE TABLE worksheet_problem (
 
46
    worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
 
47
    problemid   TEXT REFERENCES problem (identifier) NOT NULL,
 
48
    optional    BOOLEAN,
 
49
    PRIMARY KEY (worksheetid, problemid)
 
50
);
 
51
 
 
52
CREATE TABLE problem_attempt (
 
53
    problemid   TEXT REFERENCES problem (identifier) NOT NULL,
 
54
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
 
55
    worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
 
56
    date        TIMESTAMP NOT NULL,
 
57
    attempt     VARCHAR NOT NULL,
 
58
    complete    BOOLEAN NOT NULL,
 
59
    active      BOOLEAN NOT NULL DEFAULT true,
 
60
    PRIMARY KEY (problemid,loginid,worksheetid,date)
 
61
);
 
62
 
 
63
CREATE TABLE problem_save (
 
64
    problemid   TEXT REFERENCES problem (identifier) NOT NULL,
 
65
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
 
66
    worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
 
67
    date        TIMESTAMP NOT NULL,
 
68
    text        TEXT NOT NULL,
 
69
    PRIMARY KEY (problemid,loginid, worksheetid)
 
70
);
 
71
 
 
72
CREATE TABLE test_suite (
 
73
    suiteid     SERIAL PRIMARY KEY,
 
74
    problemid   TEXT REFERENCES problem (identifier) NOT NULL,
 
75
    description TEXT,
 
76
    seq_no      INT4,
 
77
    function    TEXT,
 
78
    stdin       TEXT
 
79
);
 
80
 
 
81
CREATE TABLE test_case (
 
82
    testid          SERIAL PRIMARY KEY,
 
83
    suiteid         INT4 REFERENCES test_suite (suiteid) NOT NULL,
 
84
    passmsg         TEXT,
 
85
    failmsg         TEXT,
 
86
    test_default    TEXT,
 
87
    seq_no          INT4
 
88
);
 
89
 
 
90
CREATE TABLE suite_variables (
 
91
    varid       SERIAL PRIMARY KEY,
 
92
    suiteid     INT4 REFERENCES test_suite (suiteid) NOT NULL,
 
93
    var_name    TEXT,
 
94
    var_value   TEXT,
 
95
    var_type    TEXT NOT NULL,
 
96
    arg_no      INT4
 
97
);
 
98
 
 
99
CREATE TABLE test_case_parts (
 
100
    partid          SERIAL PRIMARY KEY,
 
101
    testid          INT4 REFERENCES test_case (testid) NOT NULL,
 
102
    part_type       TEXT NOT NULL,
 
103
    test_type       TEXT,
 
104
    data            TEXT,
 
105
    filename        TEXT
 
106
);
 
107
 
 
108
COMMIT;