我用 flyway-maven-plugin 做了一些实验。我没有空数据库,所以我需要一个初始 ddl 脚本。我按照 flyway wiki 中的说明进行操作:
我将名为V1__Base_Migration.sql的 sql 脚本放在src/main/resources/db/migration中。
flyway-maven-plugin 的配置如下所示:
<build>
<plugins>
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<url>jdbc:hsqldb:hsql://localhost:9001/testdb</url>
<user>SA</user>
<password></password>
<schemas>PUBLIC</schemas>
<initialVersion>1</initialVersion>
<initialDescription>Base Migration</initialDescription>
</configuration>
</plugin>
</plugins>
</build>
当我调用mvn install flyway:init
cmd并查看数据库中的运行时,我可以找到flyway的版本表,但找不到该表,其ddl在sql脚本中。
当我查看 Maven 的调试日志时,我找不到任何关于运行 sql 脚本的提示。
[DEBUG] Excluded: classworlds:classworlds:jar:1.1
[DEBUG] Configuring mojo com.googlecode.flyway:flyway-maven-plugin:1.7:init from plugin realm ClassRealm[plugin>com.googlecode.flyway:flyway-maven-plugin:1.7, parent: sun.misc.Launcher$AppClassLoader@11799e7]
[DEBUG] Configuring mojo 'com.googlecode.flyway:flyway-maven-plugin:1.7:init' with include-project-dependencies configurator -->
[DEBUG] (f) driver = org.hsqldb.jdbcDriver
[DEBUG] (f) initialDescription = Base Migration
[DEBUG] (f) initialVersion = 1
[DEBUG] (f) schemas = PUBLIC
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@1aa246e
[DEBUG] (f) url = jdbc:hsqldb:hsql://localhost:9001/testdb
[DEBUG] (f) user = SA
[DEBUG] -- end configuration --
[DEBUG] Database: HSQL Database Engine
[INFO] Hsql does not support locking. No concurrent migration supported.
[DEBUG] Schema: PUBLIC
[INFO] Creating Metadata table: schema_version (Schema: PUBLIC)
[DEBUG] Found statement at line 17: CREATE TABLE PUBLIC.schema_version (
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 PUBLIC.schema_version_script_unique UNIQUE (script)
);
[DEBUG] Found statement at line 30: CREATE INDEX PUBLIC.schema_version_current_version_index ON PUBLIC.schema_version (current_version);
[DEBUG] Executing SQL: CREATE TABLE PUBLIC.schema_version (
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 PUBLIC.schema_version_script_unique UNIQUE (script)
)
[DEBUG] Executing SQL: CREATE INDEX PUBLIC.schema_version_current_version_index ON PUBLIC.schema_version (current_version)
[DEBUG] Metadata table created: schema_version (Schema: PUBLIC)
我做错了什么吗?如果有人可以给我一个提示,那会很酷,我做错了什么。
您可以在 [github] (https://github.com/skosmalla/flyway-maven-test) 中找到整个 Maven 测试项目
最好的祝福,
桑德拉