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.
12
-- Move the exercises from being stored as flat files, to being stored in
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;
26
CREATE TABLE problem (
27
identifier TEXT PRIMARY KEY,
36
CREATE TABLE worksheet (
37
worksheetid SERIAL PRIMARY KEY,
38
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
39
identifier VARCHAR NOT NULL,
42
UNIQUE (offeringid, identifier)
45
CREATE TABLE worksheet_problem (
46
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
47
problemid TEXT REFERENCES problem (identifier) NOT NULL,
49
PRIMARY KEY (worksheetid, problemid)
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)
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,
69
PRIMARY KEY (problemid,loginid, worksheetid)
72
CREATE TABLE test_suite (
73
suiteid SERIAL PRIMARY KEY,
74
problemid TEXT REFERENCES problem (identifier) NOT NULL,
81
CREATE TABLE test_case (
82
testid SERIAL PRIMARY KEY,
83
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
90
CREATE TABLE suite_variables (
91
varid SERIAL PRIMARY KEY,
92
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
95
var_type TEXT NOT NULL,
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,