我正在使用这种鹅味。我希望我的迁移脚本在出现错误时回滚。把我的陈述包装在里面-- +goose StatementStart
,-- +goose StatementEnd
对我不起作用。
-- +goose Up
-- SQL in section 'Up' is executed when this migration is applied
-- +goose StatementBegin
ALTER TABLE books
ADD COLUMN author VARCHAR(10) NOT NULL AFTER name;
UPDATE books
SET author = created_by
WHERE created > '2021-01-05';
-- +goose StatementEnd
-- +goose Down
-- SQL section 'Down' is executed when this migration is rolled back
-- +goose StatementBegin
ALTER TABLE books
DROP COLUMN author;
-- +goose StatementEnd
这导致Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE...
.
鹅有可能吗?还是我只需要在一个迁移文件中编写一个查询?