mirror of
https://github.com/pressly/goose.git
synced 2025-05-31 11:42:04 +00:00
Merge pull request #153 from pressly/91
Add plpgsql syntax unit test #91
This commit is contained in:
commit
acc7a55e78
@ -47,6 +47,7 @@ func TestSplitStatements(t *testing.T) {
|
|||||||
{sql: functxt, up: 2, down: 2},
|
{sql: functxt, up: 2, down: 2},
|
||||||
{sql: mysqlChangeDelimiter, up: 4, down: 0},
|
{sql: mysqlChangeDelimiter, up: 4, down: 0},
|
||||||
{sql: copyFromStdin, up: 1, down: 0},
|
{sql: copyFromStdin, up: 1, down: 0},
|
||||||
|
{sql: plpgsqlSyntax, up: 2, down: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tt {
|
for i, test := range tt {
|
||||||
@ -289,3 +290,27 @@ COPY public.django_content_type (id, app_label, model) FROM stdin;
|
|||||||
\.
|
\.
|
||||||
-- +goose StatementEnd
|
-- +goose StatementEnd
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var plpgsqlSyntax = `
|
||||||
|
-- +goose Up
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||||
|
RETURNS TRIGGER AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.updated_at = now();
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$ language 'plpgsql';
|
||||||
|
-- +goose StatementEnd
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE TRIGGER update_properties_updated_at BEFORE UPDATE ON properties FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
-- +goose StatementBegin
|
||||||
|
DROP TRIGGER update_properties_updated_at
|
||||||
|
-- +goose StatementEnd
|
||||||
|
-- +goose StatementBegin
|
||||||
|
DROP FUNCTION update_updated_at_column()
|
||||||
|
-- +goose StatementEnd
|
||||||
|
`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user