Compare commits

..

No commits in common. "9f48553f674bee9545d94f176745d50a60df44f7" and "116aa85253c56a120b576eca4c07a95db68ab31c" have entirely different histories.

View file

@ -13,6 +13,18 @@ CREATE TABLE IF NOT EXISTS languages
);
CREATE FUNCTION lng_upd_trg_fn() RETURNS TRIGGER
LANGUAGE plpgsql AS
$$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
CREATE TRIGGER lng_upd_trg BEFORE UPDATE ON languages FOR EACH ROW EXECUTE FUNCTION lng_upd_trg_fn();
CREATE TABLE IF NOT EXISTS problems
@ -22,8 +34,6 @@ CREATE TABLE IF NOT EXISTS problems
description TEXT NOT NULL,
time_limit INT NOT NULL,
memory_limit INT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY(id)
);
@ -37,8 +47,6 @@ CREATE TABLE IF NOT EXISTS contests
(
id serial NOT NULL,
name VARCHAR(300) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY(id)
);
@ -218,26 +226,11 @@ END; $$ LANGUAGE plpgsql;
CREATE TRIGGER new_subtask_trg AFTER INSERT ON subtasks FOR EACH ROW EXECUTE FUNCTION on_new_subtask();
CREATE FUNCTION updated_at_update() RETURNS TRIGGER
LANGUAGE plpgsql AS
$$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$;
CREATE TRIGGER languages_upd_trg BEFORE UPDATE ON languages FOR EACH ROW EXECUTE FUNCTION updated_at_update();
CREATE TRIGGER problems_upd_trg BEFORE UPDATE ON problems FOR EACH ROW EXECUTE FUNCTION updated_at_update();
CREATE TRIGGER contests_upd_trg BEFORE UPDATE ON contests FOR EACH ROW EXECUTE FUNCTION updated_at_update();
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP FUNCTION IF EXISTS updated_at_update CASCADE;
DROP FUNCTION IF EXISTS lng_upd_trg_fn CASCADE;
DROP FUNCTION IF EXISTS on_new_participant CASCADE;
DROP FUNCTION IF EXISTS on_new_task CASCADE;
DROP FUNCTION IF EXISTS on_new_subtask CASCADE;