为什么Maven Flyway插件无法迁移我的Hsqldb数据库?

时间:2012-03-21 03:54:24

标签: maven hsqldb flyway

我无法使用flyway和maven插件初始化和迁移HSQLDB数据库。

我的pom.xml中有这个XML块:

<plugin>
    <groupId>com.googlecode.flyway</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>1.5</version>
    <configuration>
        <driver>org.hsqldb.jdbcDriver</driver>
        <url>jdbc:hsqldb:file:${project.build.directory}/db/margarita;shutdown=true</url>
        <user>develop</user>
        <password></password>
        <schemas>margarita</schemas>
        <table>schema_history</table>
        <initialVersion>118</initialVersion>
        <initialDescription>Base Migration</initialDescription>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.2.8</version>
        </dependency>
    </dependencies>
</plugin>

当我运行此命令时:

mvn flyway:migrate

我收到此错误消息:

[INFO] --- flyway-maven-plugin:1.5:migrate (default-cli) @ Margarita ---
[INFO] Database closed
[INFO] Hsql does not support locking. No concurrent migration supported.
[INFO] Database closed
[ERROR] com.googlecode.flyway.core.exception.FlywayException: Error executing statement at line 17: CREATE TABLE MARGARITA.schema_history (
version VARCHAR(20) PRIMARY KEY,
description VARCHAR(100),
type VARCHAR(10) NOT NULL,
script VARCHAR(200) NOT NULL,
checksum INT,
installed_by VARCHAR(30) NOT NULL,
installed_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
execution_time INT,
state VARCHAR(15) NOT NULL,
current_version BIT NOT NULL,
CONSTRAINT MARGARITA.schema_history_script_unique UNIQUE (script)
)
[ERROR] Caused by org.hsqldb.HsqlException: invalid schema name: MARGARITA
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.550s
[INFO] Finished at: Tue Mar 20 21:54:06 EDT 2012
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.googlecode.flyway:flyway-maven-plugin:1.5:migrate (default-cli) on project Margarita: Flyway Error: com.googlecode.flyway.core.exception.FlywayException: Error executing statement at line 17: CREATE TABLE MARGARITA.schema_history (
[ERROR] version VARCHAR(20) PRIMARY KEY,
[ERROR] description VARCHAR(100),
[ERROR] type VARCHAR(10) NOT NULL,
[ERROR] script VARCHAR(200) NOT NULL,
[ERROR] checksum INT,
[ERROR] installed_by VARCHAR(30) NOT NULL,
[ERROR] installed_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
[ERROR] execution_time INT,
[ERROR] state VARCHAR(15) NOT NULL,
[ERROR] current_version BIT NOT NULL,
[ERROR] CONSTRAINT MARGARITA.schema_history_script_unique UNIQUE (script)
[ERROR] ): StatementCallback; uncategorized SQLException for SQL [CREATE TABLE MARGARITA.schema_history (
[ERROR] version VARCHAR(20) PRIMARY KEY,
[ERROR] description VARCHAR(100),
[ERROR] type VARCHAR(10) NOT NULL,
[ERROR] script VARCHAR(200) NOT NULL,
[ERROR] checksum INT,
[ERROR] installed_by VARCHAR(30) NOT NULL,
[ERROR] installed_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
[ERROR] execution_time INT,
[ERROR] state VARCHAR(15) NOT NULL,
[ERROR] current_version BIT NOT NULL,
[ERROR] CONSTRAINT MARGARITA.schema_history_script_unique UNIQUE (script)
[ERROR] )]; SQL state [3F000]; error code [-4850]; invalid schema name: MARGARITA; nested exception is java.sql.SQLException: invalid schema name: MARGARITA
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这不是受支持的流程吗?我以为hsqldb会自动创建引用的模式,所以我很困惑。

2 个答案:

答案 0 :(得分:1)

您的SQL脚本似乎有错误:

Caused by org.hsqldb.HsqlException: invalid schema name: MARGARITA

尝试通过从CREATE TABLE子句中删除模式名称来更新SQL脚本。示例:

CREATE TABLE schema_history (
version VARCHAR(20) PRIMARY KEY,
description VARCHAR(100),
...

答案 1 :(得分:1)

尝试运行下一个命令:mvn flyway:clean flyway:init flyway:migrate 它应该工作

看看这里:http://flywaydb.org/documentation/maven/