Compare commits
No commits in common. "6b15ecadcb72b8672dc64f063872a03a9c9923c7" and "a2e0894728a03cc075d852c54f073cce4f64d7f4" have entirely different histories.
6b15ecadcb
...
a2e0894728
1 changed files with 8 additions and 34 deletions
|
@ -9,24 +9,6 @@ BEGIN
|
|||
END;
|
||||
$$;
|
||||
|
||||
CREATE FUNCTION check_max_tasks() RETURNS TRIGGER
|
||||
LANGUAGE plpgsql AS
|
||||
$$
|
||||
DECLARE
|
||||
max_on_contest_tasks_amount integer := 50;
|
||||
BEGIN
|
||||
IF (
|
||||
SELECT count(*) FROM tasks
|
||||
WHERE contest_id = NEW.contest_id
|
||||
) >= (
|
||||
max_on_contest_tasks_amount
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Exceeded max tasks for this contest';
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS problems
|
||||
(
|
||||
id serial NOT NULL,
|
||||
|
@ -91,11 +73,6 @@ CREATE TABLE IF NOT EXISTS tasks
|
|||
CHECK (position >= 0)
|
||||
);
|
||||
|
||||
CREATE TRIGGER max_tasks_on_contest_check
|
||||
BEFORE INSERT ON tasks
|
||||
FOR EACH STATEMENT
|
||||
EXECUTE FUNCTION check_max_tasks();
|
||||
|
||||
CREATE TRIGGER on_tasks_update
|
||||
BEFORE UPDATE
|
||||
ON tasks
|
||||
|
@ -121,7 +98,6 @@ CREATE TRIGGER on_participants_update
|
|||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE updated_at_update();
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS solutions
|
||||
(
|
||||
id serial NOT NULL,
|
||||
|
@ -149,17 +125,15 @@ EXECUTE PROCEDURE updated_at_update();
|
|||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TRIGGER IF EXISTS on_solutions_update ON solutions;
|
||||
DROP TABLE IF EXISTS solutions;
|
||||
DROP TRIGGER IF EXISTS on_participants_update ON participants;
|
||||
DROP TABLE IF EXISTS participants;
|
||||
DROP TRIGGER IF EXISTS on_tasks_update ON tasks;
|
||||
DROP TRIGGER IF EXISTS max_tasks_on_contest_check ON tasks;
|
||||
DROP TABLE IF EXISTS tasks;
|
||||
DROP TRIGGER IF EXISTS on_problems_update ON problems;
|
||||
DROP TABLE IF EXISTS problems;
|
||||
DROP TRIGGER IF EXISTS on_contests_update ON contests;
|
||||
DROP TABLE IF EXISTS contests;
|
||||
DROP FUNCTION IF EXISTS updated_at_update();
|
||||
DROP FUNCTION IF EXISTS check_max_tasks();
|
||||
-- +goose StatementEnd
|
||||
DROP TRIGGER IF EXISTS on_tasks_update ON tasks;
|
||||
DROP TABLE IF EXISTS tasks;
|
||||
DROP TRIGGER IF EXISTS on_participants_update ON participants;
|
||||
DROP TABLE IF EXISTS participants;
|
||||
DROP TRIGGER IF EXISTS on_solutions_update ON solutions;
|
||||
DROP TABLE IF EXISTS solutions;
|
||||
DROP FUNCTION updated_at_update();
|
||||
-- +goose StatementEnd
|
||||
|
|
Loading…
Add table
Reference in a new issue