update schema
This commit is contained in:
parent
01e368336f
commit
6da164a4b5
1 changed files with 62 additions and 18 deletions
|
@ -47,6 +47,50 @@ CREATE INDEX ON problems USING BTREE (id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS contests
|
||||||
|
(
|
||||||
|
id serial NOT NULL,
|
||||||
|
name VARCHAR(300) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX ON contests USING BTREE (id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS contest_problem
|
||||||
|
(
|
||||||
|
contest_id INT REFERENCES contests ON DELETE CASCADE,
|
||||||
|
problem_id INT REFERENCES problems ON DELETE CASCADE,
|
||||||
|
position_name VARCHAR(10) NOT NULL, -- problem name like: A,B,A1,etc
|
||||||
|
UNIQUE (contest_id,problem_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX ON contest_problem USING BTREE (contest_id);
|
||||||
|
CREATE INDEX ON contest_problem USING BTREE (problem_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS participants
|
||||||
|
(
|
||||||
|
id serial NOT NULL,
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
contest_id INT REFERENCES contests ON DELETE CASCADE,
|
||||||
|
name varchar(200) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX ON participants USING BTREE (id);
|
||||||
|
CREATE INDEX ON participants USING BTREE (user_id);
|
||||||
|
CREATE INDEX ON participants USING BTREE (contest_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS testgroups
|
CREATE TABLE IF NOT EXISTS testgroups
|
||||||
(
|
(
|
||||||
id serial NOT NULL,
|
id serial NOT NULL,
|
||||||
|
@ -65,7 +109,7 @@ CREATE INDEX ON testgroups USING BTREE (problem_id);
|
||||||
CREATE TABLE IF NOT EXISTS solutions
|
CREATE TABLE IF NOT EXISTS solutions
|
||||||
(
|
(
|
||||||
id serial NOT NULL,
|
id serial NOT NULL,
|
||||||
user_id INT NOT NULL,
|
participant_id INT REFERENCES participants ON DELETE CASCADE,
|
||||||
problem_id INT REFERENCES problems ON DELETE CASCADE,
|
problem_id INT REFERENCES problems ON DELETE CASCADE,
|
||||||
language_id INT REFERENCES languages ON DELETE CASCADE,
|
language_id INT REFERENCES languages ON DELETE CASCADE,
|
||||||
contest_id INT NOT NULL,
|
contest_id INT NOT NULL,
|
||||||
|
@ -77,7 +121,7 @@ CREATE TABLE IF NOT EXISTS solutions
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX ON solutions USING BTREE (id);
|
CREATE INDEX ON solutions USING BTREE (id);
|
||||||
CREATE INDEX ON solutions USING BTREE (id,user_id,problem_id,language_id,contest_id);
|
CREATE INDEX ON solutions USING BTREE (id,participant_id,problem_id,language_id,contest_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,17 +158,14 @@ CREATE INDEX ON testruns USING BTREE (solution_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS contests
|
CREATE TABLE IF NOT EXISTS participant_problem
|
||||||
(
|
(
|
||||||
id serial NOT NULL,
|
participand_id INT REFERENCES participants ON DELETE CASCADE,
|
||||||
name VARCHAR(300) NOT NULL,
|
problem_id INT REFERENCES problems ON DELETE CASCADE,
|
||||||
|
result INT NOT NULL,
|
||||||
PRIMARY KEY(id)
|
best_score INT NOT NULL
|
||||||
);
|
);
|
||||||
|
-- TODO: automatic creating & deleting entries on creating & deleting users & problems to contest
|
||||||
CREATE INDEX ON contests USING BTREE (id);
|
|
||||||
|
|
||||||
|
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
@ -136,3 +177,6 @@ DROP TABLE IF EXISTS testgroups CASCADE;
|
||||||
DROP TABLE IF EXISTS testruns CASCADE;
|
DROP TABLE IF EXISTS testruns CASCADE;
|
||||||
DROP TABLE IF EXISTS problems CASCADE;
|
DROP TABLE IF EXISTS problems CASCADE;
|
||||||
DROP TABLE IF EXISTS contests CASCADE;
|
DROP TABLE IF EXISTS contests CASCADE;
|
||||||
|
DROP TABLE IF EXISTS contest_problem CASCADE;
|
||||||
|
DROP TABLE IF EXISTS participants CASCADE;
|
||||||
|
DROP TABLE IF EXISTS participant_problem CASCADE;
|
||||||
|
|
Loading…
Reference in a new issue