fixed schema mistakes
This commit is contained in:
parent
bef52da87f
commit
b0db5f123d
1 changed files with 8 additions and 10 deletions
|
@ -5,11 +5,11 @@ CREATE TABLE IF NOT EXISTS tests
|
||||||
id serial NOT NULL,
|
id serial NOT NULL,
|
||||||
problem_id INT NOT NULL,
|
problem_id INT NOT NULL,
|
||||||
|
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX ON users USING B-TREE (id);
|
CREATE INDEX ON tests USING BTREE (id);
|
||||||
CREATE INDEX ON users USING B-TREE (problem_id);
|
CREATE INDEX ON tests USING BTREE (problem_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS languages
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,20 +47,18 @@ EXECUTE PROCEDURE lng_upd_trg_fn();
|
||||||
CREATE TABLE IF NOT EXISTS solutions
|
CREATE TABLE IF NOT EXISTS solutions
|
||||||
(
|
(
|
||||||
id serial NOT NULL,
|
id serial NOT NULL,
|
||||||
user_id INT REFERENCES users ON DELETE CASCADE,
|
user_id INT NOT NULL,
|
||||||
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,
|
||||||
solution_hash CHAR(128) NOT NULL,
|
solution_hash CHAR(128) NOT NULL,
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id)
|
||||||
CHECK (length(name) != 0),
|
|
||||||
CHECK (length(description) != 0)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX ON users USING B-TREE (id);
|
CREATE INDEX ON solutions USING BTREE (id);
|
||||||
CREATE INDEX ON users USING B-TREE (id,user_id,problem_id,language_id);
|
CREATE INDEX ON solutions USING BTREE (id,user_id,problem_id,language_id);
|
||||||
|
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue