/
githubmirror
/
goose
Обзор
Документация
Войти
/
githubmirror
/
goose
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/sqlparser/testdata/valid-up/test01/input.sql
36 строк
1004 B
Oleg Balunenko
feat: Make goose annotations case-insensitive (#704)
04 мар 2024, 17:35
Не верифицирован
04 мар 2024, 17:35
48100ea
Код
Авторство
О чём код?
-- +goose UP CREATE TABLE emp ( empname text, salary integer, last_date timestamp, last_user text ); -- +goose statementBegin CREATE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$ BEGIN -- Check that empname and salary are given IF NEW.empname IS NULL THEN RAISE EXCEPTION 'empname cannot be null'; END IF; IF NEW.salary IS NULL THEN RAISE EXCEPTION '% cannot have null salary', NEW.empname; END IF; -- Who works for us when they must pay for it? IF NEW.salary < 0 THEN RAISE EXCEPTION '% cannot have a negative salary', NEW.empname; END IF; -- Remember who changed the payroll when NEW.last_date := current_timestamp; NEW.last_user := current_user; RETURN NEW; END; $emp_stamp$ LANGUAGE plpgsql; -- +goose StatementEnd CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE FUNCTION emp_stamp(); -- +goose Down