0

我正在使用 flyway 1.7 的 api 来迁移 hsql 数据库。我对存储过程有一些问题。以下脚本适用于 hsql 数据库管理器:

CREATE TABLE CUSTOMER (
  firstname VARCHAR(50),
  lastname VARCHAR(50),
  mod_ts TIMESTAMP
);

CREATE PROCEDURE new_customer(firstname VARCHAR(50), lastname VARCHAR(50), address VARCHAR(100))
  MODIFIES SQL DATA
    BEGIN ATOMIC
    INSERT INTO CUSTOMER VALUES (firstname, lastname, CURRENT_TIMESTAMP);
  END

但我认为在 flyway 迁移期间,脚本未正确解析(看起来 flyway 认为第二条语句在分号之后结束)。

这是相应的日志输出:

DEBUG 2012-11-22 14:16:00,232 [main] (SqlScript.java:161) - Found statement at line 1: create table CUSTOMER (
firstname varchar(50),
lastname varchar(50),
mod_ts timestamp
);
DEBUG 2012-11-22 14:16:00,232 [main] (SqlScript.java:161) - Found statement at line 7: CREATE PROCEDURE new_customer(firstname VARCHAR(50), lastname VARCHAR(50), address VARCHAR(100))
MODIFIES SQL DATA
BEGIN ATOMIC
INSERT INTO CUSTOMER VALUES (firstname, lastname, CURRENT_TIMESTAMP);
DEBUG 2012-11-22 14:16:00,232 [main] (SqlStatement.java:75) - Executing SQL: create table CUSTOMER (
firstname varchar(50),
lastname varchar(50),
mod_ts timestamp
)
DEBUG 2012-11-22 14:16:00,232 [main] (SqlStatement.java:75) - Executing SQL: CREATE PROCEDURE new_customer(firstname VARCHAR(50), lastname VARCHAR(50), address VARCHAR(100))
MODIFIES SQL DATA
BEGIN ATOMIC
INSERT INTO CUSTOMER VALUES (firstname, lastname, CURRENT_TIMESTAMP)
ERROR 2012-11-22 14:16:00,232 [main] (DbMigrator.java:231) - com.googlecode.flyway.core.exception.FlywayException: Error executing statement at line 7: CREATE PROCEDURE new_customer(firstname VARCHAR(50), lastname VARCHAR(50), address VARCHAR(100))
MODIFIES SQL DATA
BEGIN ATOMIC
INSERT INTO CUSTOMER VALUES (firstname, lastname, CURRENT_TIMESTAMP)
ERROR 2012-11-22 14:16:00,232 [main] (DbMigrator.java:236) - Caused by org.hsqldb.HsqlException: unexpected end of statement:  required: ; : line: 4

有没有办法解决这个问题?

编辑我刚刚做了一个有趣的观察。如果我使用 flyway 命令行程序,那么它可以完美运行。

4

1 回答 1

1

升级到 Flyway 2.0。它增加了对 Hsql 中 BEGIN ATOMIC 块的支持。

于 2012-11-22T17:45:28.533 回答